From 1b9915045de9b745c47c7a806c0c5d92c00d11fc Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Tue, 4 Oct 2016 12:46:36 +0200 Subject: [PATCH] Use fixed library versions in build init templates This removes the dynamic version calculation for libraries from the build init project and replaces it with fixed versions (latest released) of the libraries. The code for updating the version file with newer stable releases, has been moved to the 'gradle promote' build and will be automatically executed when a new release cycle is started. In case it is needed, selected versions can still be manually updated during a release cycle. +review REVIEW-6282 --- subprojects/build-init/build-init.gradle | 61 ------------------- .../templates/library-versions.properties | 10 +++ 2 files changed, 10 insertions(+), 61 deletions(-) create mode 100644 subprojects/build-init/src/main/resources/org/gradle/buildinit/tasks/templates/library-versions.properties diff --git a/subprojects/build-init/build-init.gradle b/subprojects/build-init/build-init.gradle index 6ec4c64bc69c..f6dced245128 100644 --- a/subprojects/build-init/build-init.gradle +++ b/subprojects/build-init/build-init.gradle @@ -22,66 +22,5 @@ dependencies { integTestRuntime project(':scala') } -dependencies { - components { - all { ComponentMetadataDetails details -> - def version = details.id.version - if(version.matches("(\\d\\.?)+")){ - details.status = "release" - } else { - details.status = "integration" - } - details.statusScheme = ["integration", "release"] - } - } -} - -task generateTemplateVersionFile(type: GenerateVersionProperties) { - outputFile = new File(generatedResourcesDir, "org/gradle/buildinit/tasks/templates/library-versions.properties") -} - -sourceSets.main.resources.srcDir generatedResourcesDir -processResources.dependsOn generateTemplateVersionFile - -eclipseClasspath.dependsOn generateTemplateVersionFile -ideaModule.dependsOn generateTemplateVersionFile - -class GenerateVersionProperties extends DefaultTask { - - @OutputFile - File outputFile - - @TaskAction - void generateFile() { - resolveFiles() - } - - void resolveFiles() { - Properties versionProperties = new Properties() - - findLatest('scala-library', 'org.scala-lang:scala-library:latest.release', versionProperties) - def scalaVersion = VersionNumber.parse(versionProperties['scala-library']) - versionProperties.put('scala', "${scalaVersion.major}.${scalaVersion.minor}" as String) - findLatest('scalatest', "org.scalatest:scalatest_${versionProperties.scala}:latest.release", versionProperties) - findLatest('scala-xml', "org.scala-lang.modules:scala-xml_${versionProperties.scala}:latest.release", versionProperties) - findLatest('groovy', 'org.codehaus.groovy:groovy:latest.release', versionProperties) - findLatest('junit', 'junit:junit:latest.release', versionProperties) - findLatest('testng', 'org.testng:testng:latest.release', versionProperties) - findLatest('slf4j', 'org.slf4j:slf4j-api:latest.release', versionProperties) - def groovyVersion = VersionNumber.parse(versionProperties['groovy']) - versionProperties.put('spock', "1.0-groovy-${groovyVersion.major}.${groovyVersion.minor}" as String) - - org.gradle.build.ReproduciblePropertiesWriter.store(versionProperties, outputFile, "Version values used in build-init templates") - } - - private void findLatest(String name, String notation, Properties dest) { - def libDependencies = [ project.dependencies.create(notation) ] - def templateVersionConfiguration = project.configurations.detachedConfiguration(libDependencies as Dependency[]) - templateVersionConfiguration.transitive = false - ResolutionResult resolutionResult = templateVersionConfiguration.incoming.resolutionResult - resolutionResult.allComponents.findAll { it != resolutionResult.root }. each { dep -> dest.put(name, dep.id.version) } - } -} - useTestFixtures() useClassycle() diff --git a/subprojects/build-init/src/main/resources/org/gradle/buildinit/tasks/templates/library-versions.properties b/subprojects/build-init/src/main/resources/org/gradle/buildinit/tasks/templates/library-versions.properties new file mode 100644 index 000000000000..b08d25f289ff --- /dev/null +++ b/subprojects/build-init/src/main/resources/org/gradle/buildinit/tasks/templates/library-versions.properties @@ -0,0 +1,10 @@ +# Version values used in build-init templates +scalatest=3.0.0 +scala-xml=1.0.6 +scala-library=2.11.8 +testng=6.9.13.8 +slf4j=1.7.21 +scala=2.11 +groovy=2.4.7 +junit=4.12 +spock=1.0-groovy-2.4