@@ -771,10 +771,11 @@ class BeamModulePlugin implements Plugin<Project> {
771
771
772
772
// Create a task which emulates the maven-archiver plugin in generating a
773
773
// pom.properties file.
774
+ def pomPropertiesFile = " ${ project.buildDir} /publications/mavenJava/pom.properties"
774
775
project. task(' generatePomPropertiesFileForMavenJavaPublication' ) {
775
- outputs. file " ${ project.buildDir } /publications/mavenJava/pom.properties "
776
+ outputs. file " ${ pomPropertiesFile } "
776
777
doLast {
777
- new File (" ${ project.buildDir } /publications/mavenJava/pom.properties " ). text =
778
+ new File (" ${ pomPropertiesFile } " ). text =
778
779
""" version=${ project.version}
779
780
groupId=${ project.group}
780
781
artifactId=${ project.name}
@@ -785,10 +786,23 @@ artifactId=${project.name}
785
786
// Have the shaded include both the generate pom.xml and its properties file
786
787
// emulating the behavior of the maven-archiver plugin.
787
788
project. shadowJar {
789
+ def pomFile = " ${ project.buildDir} /publications/mavenJava/pom-default.xml"
790
+
791
+ // Validate that the artifacts exist before copying them into the jar.
792
+ doFirst {
793
+ if (! project. file(" ${ pomFile} " ). exists()) {
794
+ throw new GradleException (" Expected ${ pomFile} to have been generated by the 'generatePomFileForMavenJavaPublication' task." )
795
+ }
796
+ if (! project. file(" ${ pomPropertiesFile} " ). exists()) {
797
+ throw new GradleException (" Expected ${ pomPropertiesFile} to have been generated by the 'generatePomPropertiesFileForMavenJavaPublication' task." )
798
+ }
799
+ }
800
+
788
801
dependsOn ' generatePomFileForMavenJavaPublication'
789
- into(" META-INF/maven/${ project.group} /${ project.name} " ) { from " ${ project.buildDir} /publications/mavenJava/pom.xml" }
802
+ into(" META-INF/maven/${ project.group} /${ project.name} " ) { from " ${ pomFile} " }
803
+
790
804
dependsOn project. generatePomPropertiesFileForMavenJavaPublication
791
- into(" META-INF/maven/${ project.group} /${ project.name} " ) { from " ${ project.buildDir } /publications/mavenJava/pom.properties " }
805
+ into(" META-INF/maven/${ project.group} /${ project.name} " ) { from " ${ pomPropertiesFile } " }
792
806
}
793
807
794
808
// Only build artifacts for archives if we are publishing
0 commit comments