Skip to content

Commit

Permalink
Use fixed library versions in build init templates
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jjohannes committed Oct 4, 2016
1 parent 5e612f0 commit 1b99150
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 61 deletions.
61 changes: 0 additions & 61 deletions subprojects/build-init/build-init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1b99150

Please sign in to comment.