Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BEAM-5351] Fix missing pom.xml file in artifact jar. #6358

Merged
merged 1 commit into from Sep 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -771,10 +771,11 @@ class BeamModulePlugin implements Plugin<Project> {

// Create a task which emulates the maven-archiver plugin in generating a
// pom.properties file.
def pomPropertiesFile = "${project.buildDir}/publications/mavenJava/pom.properties"
project.task('generatePomPropertiesFileForMavenJavaPublication') {
outputs.file "${project.buildDir}/publications/mavenJava/pom.properties"
outputs.file "${pomPropertiesFile}"
doLast {
new File("${project.buildDir}/publications/mavenJava/pom.properties").text =
new File("${pomPropertiesFile}").text =
"""version=${project.version}
groupId=${project.group}
artifactId=${project.name}
Expand All @@ -785,10 +786,23 @@ artifactId=${project.name}
// Have the shaded include both the generate pom.xml and its properties file
// emulating the behavior of the maven-archiver plugin.
project.shadowJar {
def pomFile = "${project.buildDir}/publications/mavenJava/pom-default.xml"

// Validate that the artifacts exist before copying them into the jar.
doFirst {
if (!project.file("${pomFile}").exists()) {
throw new GradleException("Expected ${pomFile} to have been generated by the 'generatePomFileForMavenJavaPublication' task.")
}
if (!project.file("${pomPropertiesFile}").exists()) {
throw new GradleException("Expected ${pomPropertiesFile} to have been generated by the 'generatePomPropertiesFileForMavenJavaPublication' task.")
}
}

dependsOn 'generatePomFileForMavenJavaPublication'
into("META-INF/maven/${project.group}/${project.name}") { from "${project.buildDir}/publications/mavenJava/pom.xml" }
into("META-INF/maven/${project.group}/${project.name}") { from "${pomFile}" }

dependsOn project.generatePomPropertiesFileForMavenJavaPublication
into("META-INF/maven/${project.group}/${project.name}") { from "${project.buildDir}/publications/mavenJava/pom.properties" }
into("META-INF/maven/${project.group}/${project.name}") { from "${pomPropertiesFile}" }
}

// Only build artifacts for archives if we are publishing
Expand Down