Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@behrangsa
Created October 7, 2016 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save behrangsa/2e44c7bdd44171260123469b5144b1af to your computer and use it in GitHub Desktop.
Save behrangsa/2e44c7bdd44171260123469b5144b1af to your computer and use it in GitHub Desktop.
Maven publication closure is evaluated too early
group 'org.behrang.labs'
version '1.0-SNAPSHOT'
apply plugin: 'maven-publish'
repositories {
mavenCentral()
}
task clean {
doLast {
println "clean"
if (buildDir.exists()) {
buildDir.listFiles().each { f -> f.delete() }
}
}
}
task randomArtifacts {
doLast {
println "randomArtifacts"
buildDir.mkdirs();
def artifactCount = (int) (Math.random() * 9) + 1
(1..artifactCount).each {
new File(buildDir, "artifact-${it}.rpm").text = "Artifact ${it}"
}
println "Created ${artifactCount} artifacts."
}
}
publishing {
publications {
mavenRpm(MavenPublication) {
println "mavenRpm"
def rpms = buildDir.listFiles({ f -> f.name.endsWith(".rpm")} as FileFilter)
rpms.each { f ->
println f.absolutePath
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment