You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.2 KiB
56 lines
2.2 KiB
apply plugin: 'release' |
|
|
|
[ uploadIvyLocal: 'uploadLocal', uploadArtifactory: 'artifactoryPublish', buildWithArtifactory: 'build' ].each { key, value -> |
|
// Call out to compile against internal repository |
|
task "${key}"(type: GradleBuild) { |
|
startParameter = project.gradle.startParameter.newInstance() |
|
doFirst { |
|
startParameter.projectProperties = [status: project.status] |
|
} |
|
startParameter.addInitScript( file('gradle/netflix-oss.gradle') ) |
|
startParameter.getExcludedTaskNames().add('check') |
|
tasks = [ 'build', value ] |
|
} |
|
} |
|
|
|
// Marker task for following code to key in on |
|
task releaseCandidate(dependsOn: release) |
|
task forceCandidate { |
|
onlyIf { gradle.taskGraph.hasTask(releaseCandidate) } |
|
doFirst { project.status = 'candidate' } |
|
} |
|
release.dependsOn(forceCandidate) |
|
|
|
task uploadMavenCentral(dependsOn: subprojects.tasks.uploadMavenCentral) |
|
task releaseSnapshot(dependsOn: [uploadArtifactory, uploadMavenCentral]) |
|
|
|
// Ensure our versions look like the project status before publishing |
|
task verifyStatus << { |
|
def hasSnapshot = version.contains('-SNAPSHOT') |
|
if (project.status == 'snapshot' && !hasSnapshot) { |
|
throw new GradleException("Version (${version}) needs -SNAPSHOT if publishing snapshot") |
|
} |
|
} |
|
uploadArtifactory.dependsOn(verifyStatus) |
|
uploadMavenCentral.dependsOn(verifyStatus) |
|
|
|
// Ensure upload happens before taggging but after all pre-checks |
|
createReleaseTag.dependsOn([uploadArtifactory, uploadMavenCentral]) |
|
|
|
gradle.taskGraph.whenReady { taskGraph -> |
|
def hasRelease = taskGraph.hasTask('commitNewVersion') |
|
def indexOf = { return taskGraph.allTasks.indexOf(it) } |
|
|
|
if (hasRelease) { |
|
assert indexOf(build) < indexOf(unSnapshotVersion), 'build target has to be after unSnapshotVersion' |
|
assert indexOf(uploadMavenCentral) < indexOf(preTagCommit), 'preTagCommit has to be after uploadMavenCentral' |
|
assert indexOf(uploadArtifactory) < indexOf(preTagCommit), 'preTagCommit has to be after uploadArtifactory' |
|
} |
|
} |
|
|
|
// Prevent plugin from asking for a version number interactively |
|
ext.'gradle.release.useAutomaticVersion' = "true" |
|
|
|
release { |
|
git.requireBranch = null |
|
}
|
|
|