Skip to content

Commit

Permalink
Test and improve gradle configuration cache
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgrefer committed Aug 9, 2023
1 parent 6bdcaee commit 2654bd2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 6 deletions.
1 change: 0 additions & 1 deletion examples/gradle.properties

This file was deleted.

5 changes: 5 additions & 0 deletions examples/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org.gradle.parallel=true
org.gradle.caching=true

org.gradle.configuration-cache=false
org.gradle.configuration-cache.problems=warn
2 changes: 2 additions & 0 deletions examples/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
rootProject.name = 'gradle-plugins-examples'

enableFeaturePreview "STABLE_CONFIGURATION_CACHE"

includeBuild '..'

include ":compress"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.freefair.gradle.plugins.git;

import org.codehaus.groovy.runtime.ProcessGroovyMethods;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.logging.Logger;
Expand Down Expand Up @@ -115,8 +114,15 @@ else if (GitUtil.isCircleCi()) {
}

try {
Process execute = ProcessGroovyMethods.execute("git describe --tags --exact-match --dirty=-SNAPSHOT");
String gitTag = ProcessGroovyMethods.getText(execute).trim();
String gitTag = project.getProviders()
.exec(execSpec -> {
execSpec.setWorkingDir(project.getProjectDir());
execSpec.commandLine("git", "describe", "--tags", "--exact-match", "--dirty=-SNAPSHOT");
})
.getStandardOutput()
.getAsText()
.get()
.trim();

if (!gitTag.isEmpty()) {
String version = resolveTagVersion(gitTag);
Expand Down Expand Up @@ -149,8 +155,15 @@ else if (GitUtil.isCircleCi()) {
}

try {
Process execute = ProcessGroovyMethods.execute("git symbolic-ref --short HEAD");
String gitBranch = ProcessGroovyMethods.getText(execute).trim();
String gitBranch = project.getProviders()
.exec(execSpec -> {
execSpec.setWorkingDir(project.getProjectDir());
execSpec.commandLine("git", "symbolic-ref", "--short", "HEAD");
})
.getStandardOutput()
.getAsText()
.get()
.trim();

if (!gitBranch.isEmpty()) {
String version = resolveBranchVersion(gitBranch);
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
org.gradle.parallel=true
org.gradle.caching=true

org.gradle.configuration-cache=false
org.gradle.configuration-cache.problems=warn
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ plugins {
id "com.gradle.enterprise" version "3.14.1"
}

enableFeaturePreview "STABLE_CONFIGURATION_CACHE"

boolean isCiServer = System.getenv().containsKey("CI")

gradleEnterprise {
Expand Down

0 comments on commit 2654bd2

Please sign in to comment.