diff options
author | Rene Groeschke <rene@gradle.com> | 2016-04-12 21:26:54 +0200 |
---|---|---|
committer | Rene Groeschke <rene@gradle.com> | 2016-04-12 21:28:16 +0200 |
commit | 07502db354b20f0527cd927c0a785031500fddfe (patch) | |
tree | ed6ddd69f87ba00f3f3214a3b23ebf38e6327354 | |
parent | edb3e94f2e2c14b6f6cd899f0fe5d8227c7f2dbd (diff) | |
download | frege-gradle-plugin-07502db354b20f0527cd927c0a785031500fddfe.tar.gz frege-gradle-plugin-07502db354b20f0527cd927c0a785031500fddfe.tar.bz2 frege-gradle-plugin-07502db354b20f0527cd927c0a785031500fddfe.zip |
Add support for >gradle 2.12
- update wrapper to 2.12
- fix sourcedirectory setup
- add integTest coverage for 2.12
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 53636 -> 53216 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 4 | ||||
-rwxr-xr-x | gradlew | 46 | ||||
-rw-r--r-- | gradlew.bat | 8 | ||||
-rw-r--r-- | src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy | 6 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/DefaultFregeSourceSet.java | 8 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy | 26 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/FregeSourceSet.java | 1 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy | 30 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy | 7 | ||||
-rw-r--r-- | src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java | 5 |
11 files changed, 107 insertions, 34 deletions
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differindex 9411448..ba3586f 100644 --- a/gradle/wrapper/gradle-wrapper.jar +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2aae013..2a6d1bb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Nov 18 11:44:20 WET 2015 +#Tue Apr 12 21:02:27 CEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,26 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -85,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then diff --git a/gradlew.bat b/gradlew.bat index aec9973..f6d5974 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,7 +46,7 @@ echo location of your Java installation. goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
diff --git a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy index 4142790..2acfa9d 100644 --- a/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy +++ b/src/integTest/groovy/frege/gradle/plugins/FregePluginIntegTest.groovy @@ -29,9 +29,11 @@ class FregePluginIntegTest extends AbstractFregeIntegrationSpec { """ when: - def result = run("classes") + def result = run(gradleVersion, "classes") then: result.task(":compileFrege").outcome == UP_TO_DATE + where: + gradleVersion << ["2.8", "2.11", "2.12"] } @Unroll @@ -55,6 +57,8 @@ class FregePluginIntegTest extends AbstractFregeIntegrationSpec { where: fregeVersion | gradleVersion + DEFAULT_FREGE_VERSION | "2.12" + "3.22.367-g2737683" | "2.12" DEFAULT_FREGE_VERSION | "2.9" DEFAULT_FREGE_VERSION | "2.8" "3.22.367-g2737683" | "2.9" diff --git a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java b/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java index 3a9bcfc..a1650a1 100644 --- a/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java +++ b/src/main/groovy/frege/gradle/DefaultFregeSourceSet.java @@ -2,18 +2,16 @@ package frege.gradle; import groovy.lang.Closure; import org.gradle.api.file.SourceDirectorySet; -import org.gradle.api.internal.file.DefaultSourceDirectorySet; -import org.gradle.api.internal.file.FileResolver; import org.gradle.util.ConfigureUtil; public class DefaultFregeSourceSet implements FregeSourceSet { private final SourceDirectorySet frege; private final SourceDirectorySet allFrege; - public DefaultFregeSourceSet(String displayName, FileResolver fileResolver) { - this.frege = new DefaultSourceDirectorySet(String.format("%s Frege source", new Object[]{displayName}), fileResolver); + public DefaultFregeSourceSet(String displayName, FregeSourceSetDirectoryFactory sourceSetFactory) { + this.frege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); this.frege.getFilter().include(new String[]{"**/*.fr"}); - this.allFrege = new DefaultSourceDirectorySet(String.format("%s Frege source", new Object[]{displayName}), fileResolver); + this.allFrege = sourceSetFactory.newSourceSetDirectory(String.format("%s Frege source", new Object[]{displayName})); this.allFrege.source(this.frege); this.allFrege.getFilter().include(new String[]{"**/*.fr"}); } diff --git a/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy b/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy new file mode 100644 index 0000000..35110f5 --- /dev/null +++ b/src/main/groovy/frege/gradle/FregeSourceDirectorySet.groovy @@ -0,0 +1,26 @@ +package frege.gradle + +import org.gradle.api.file.FileTree +import org.gradle.api.tasks.util.PatternFilterable + +interface FregeSourceDirectorySet extends PatternFilterable { + def String getName() + + def FregeSourceDirectorySet srcDir(Object srcPath) + + def FregeSourceDirectorySet srcDirs(Object... srcPaths) + + def Set<File> getSrcDirs() + + def FregeSourceDirectorySet setSrcDirs(Iterable<?> srcPaths) + + def FileTree getFiles() + + def PatternFilterable getFilter() + + def FregeSourceSetOutputs getOutput() + + def String getGeneratorTaskName() + + boolean contains(File file) +}
\ No newline at end of file diff --git a/src/main/groovy/frege/gradle/FregeSourceSet.java b/src/main/groovy/frege/gradle/FregeSourceSet.java index 7540930..27654f1 100644 --- a/src/main/groovy/frege/gradle/FregeSourceSet.java +++ b/src/main/groovy/frege/gradle/FregeSourceSet.java @@ -4,4 +4,5 @@ import org.gradle.api.file.SourceDirectorySet; public interface FregeSourceSet { SourceDirectorySet getFrege(); + SourceDirectorySet getAllFrege(); } diff --git a/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy b/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy new file mode 100644 index 0000000..96abc8f --- /dev/null +++ b/src/main/groovy/frege/gradle/FregeSourceSetDirectoryFactory.groovy @@ -0,0 +1,30 @@ +package frege.gradle + +import org.gradle.api.file.SourceDirectorySet +import org.gradle.api.internal.file.DefaultSourceDirectorySet +import org.gradle.api.internal.file.FileResolver +import org.gradle.api.internal.file.SourceDirectorySetFactory +import org.gradle.api.internal.project.ProjectInternal +import org.gradle.util.GradleVersion + +public class FregeSourceSetDirectoryFactory { + private final boolean useFactory; + private final FileResolver fileResolver + private final ProjectInternal project + + public FregeSourceSetDirectoryFactory(ProjectInternal project, FileResolver fileResolver) { + this.fileResolver = fileResolver + this.project = project + this.useFactory = GradleVersion.current().compareTo(GradleVersion.version("2.12")) >= 0; + + } + + public SourceDirectorySet newSourceSetDirectory(String displayName) { + if (useFactory) { + SourceDirectorySetFactory factory = project.getServices().get(SourceDirectorySetFactory.class); + return factory.create(displayName); + } else { + return new DefaultSourceDirectorySet(displayName, fileResolver); + } + } +} diff --git a/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy b/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy new file mode 100644 index 0000000..07e90a3 --- /dev/null +++ b/src/main/groovy/frege/gradle/FregeSourceSetOutputs.groovy @@ -0,0 +1,7 @@ +package frege.gradle + +import org.gradle.api.file.FileCollection + +interface FregeSourceSetOutputs { + FileCollection getDirs() +}
\ No newline at end of file diff --git a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java index 6d7a639..f45dae4 100644 --- a/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java +++ b/src/main/groovy/frege/gradle/plugins/FregeBasePlugin.java @@ -1,6 +1,7 @@ package frege.gradle.plugins; import frege.gradle.DefaultFregeSourceSet; +import frege.gradle.FregeSourceSetDirectoryFactory; import frege.gradle.tasks.FregeCompile; import org.gradle.api.Action; import org.gradle.api.Plugin; @@ -8,6 +9,7 @@ import org.gradle.api.Project; import org.gradle.api.file.FileTreeElement; import org.gradle.api.internal.file.FileResolver; import org.gradle.api.internal.plugins.DslObject; +import org.gradle.api.internal.project.ProjectInternal; import org.gradle.api.internal.tasks.DefaultSourceSet; import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaPluginConvention; @@ -44,7 +46,8 @@ public class FregeBasePlugin implements Plugin<Project> { private void configureSourceSetDefaults(final JavaBasePlugin javaBasePlugin) { project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().all(new Action<SourceSet>() { public void execute(final SourceSet sourceSet) { - final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), fileResolver); + FregeSourceSetDirectoryFactory factory = new FregeSourceSetDirectoryFactory((ProjectInternal) project, fileResolver); + final DefaultFregeSourceSet fregeSourceSet = new DefaultFregeSourceSet(((DefaultSourceSet) sourceSet).getDisplayName(), factory); new DslObject(sourceSet).getConvention().getPlugins().put("frege", fregeSourceSet); final String defaultSourcePath = String.format("src/%s/frege", sourceSet.getName()); |