Skip to content

Commit 7cd7721

Browse files
committed
Force attach a fake jar with non "jar" artifacts
Follow up for #18396: which is reverted with this change When you upload any `jar` artifact you have to provide the `jar` file, javadocs and sources. For distribution, we changed from `pom` artifact to `jar` in order to be able to run integration tests. But we never generate any jar, sources or javadoc because they don't exist. This PR adds a FAKE file in `src/main/resources`. So Maven is able to generate the JAR file which is uploaded to Sonatype. Sources are then automatically added. To generate the javadoc file, we need also to tell maven that javadoc will be based on this `src/main/resources` dir. As a file exists in it, javadoc is generated as well. ``` [INFO] --- maven-install-plugin:2.5.2:install (default-install) @ elasticsearch --- [INFO] Installing /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/distribution/zip/target/elasticsearch-2.4.0-SNAPSHOT.jar to /Users/dpilato/.m2/repository/org/elasticsearch/distribution/zip/elasticsearch/2.4.0-SNAPSHOT/elasticsearch-2.4.0-SNAPSHOT.jar [INFO] Installing /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/distribution/zip/pom.xml to /Users/dpilato/.m2/repository/org/elasticsearch/distribution/zip/elasticsearch/2.4.0-SNAPSHOT/elasticsearch-2.4.0-SNAPSHOT.pom [INFO] Installing /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/distribution/zip/target/elasticsearch-2.4.0-SNAPSHOT-javadoc.jar to /Users/dpilato/.m2/repository/org/elasticsearch/distribution/zip/elasticsearch/2.4.0-SNAPSHOT/elasticsearch-2.4.0-SNAPSHOT-javadoc.jar [INFO] Installing /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/distribution/zip/target/elasticsearch-2.4.0-SNAPSHOT-sources.jar to /Users/dpilato/.m2/repository/org/elasticsearch/distribution/zip/elasticsearch/2.4.0-SNAPSHOT/elasticsearch-2.4.0-SNAPSHOT-sources.jar [INFO] Installing /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/distribution/zip/target/releases/elasticsearch-2.4.0-SNAPSHOT.zip to /Users/dpilato/.m2/repository/org/elasticsearch/distribution/zip/elasticsearch/2.4.0-SNAPSHOT/elasticsearch-2.4.0-SNAPSHOT.zip ``` Backport of #18404 in 2.3 branch: (cherry picked from commit f9d1db6)
1 parent c935436 commit 7cd7721

File tree

7 files changed

+44
-14
lines changed

7 files changed

+44
-14
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is used to generate a FAKE jar which is needed by Sonatype
2+
to validate the artifact.
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is used to generate a FAKE jar which is needed by Sonatype
2+
to validate the artifact.
3+

distribution/pom.xml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,25 @@
149149

150150
<build>
151151
<plugins>
152+
<!-- Always generate a Javadoc file even if we don't have any java source
153+
but only resources
154+
-->
152155
<plugin>
153156
<groupId>org.apache.maven.plugins</groupId>
154-
<artifactId>maven-source-plugin</artifactId>
155-
<configuration>
156-
<includePom>true</includePom>
157-
</configuration>
157+
<artifactId>maven-jar-plugin</artifactId>
158+
<executions>
159+
<execution>
160+
<id>empty-javadoc-jar</id>
161+
<phase>package</phase>
162+
<goals>
163+
<goal>jar</goal>
164+
</goals>
165+
<configuration>
166+
<classifier>javadoc</classifier>
167+
<classesDirectory>${basedir}/src/main/resources</classesDirectory>
168+
</configuration>
169+
</execution>
170+
</executions>
158171
</plugin>
159172

160173
<!-- We copy libs for deb and rpm -->
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is used to generate a FAKE jar which is needed by Sonatype
2+
to validate the artifact.
3+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is used to generate a FAKE jar which is needed by Sonatype
2+
to validate the artifact.
3+

plugins/site-example/pom.xml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@
2727

2828
<build>
2929
<plugins>
30-
<plugin>
31-
<groupId>org.apache.maven.plugins</groupId>
32-
<artifactId>maven-source-plugin</artifactId>
33-
<configuration>
34-
<includePom>true</includePom>
35-
</configuration>
36-
</plugin>
37-
3830
<plugin>
3931
<groupId>org.apache.maven.plugins</groupId>
4032
<artifactId>maven-assembly-plugin</artifactId>
@@ -44,9 +36,19 @@
4436
<groupId>org.apache.maven.plugins</groupId>
4537
<artifactId>maven-jar-plugin</artifactId>
4638
<executions>
39+
<!-- Always generate a Javadoc file even if we don't have any java source
40+
but only resources
41+
-->
4742
<execution>
48-
<id>default-jar</id>
49-
<phase>none</phase>
43+
<id>empty-javadoc-jar</id>
44+
<phase>package</phase>
45+
<goals>
46+
<goal>jar</goal>
47+
</goals>
48+
<configuration>
49+
<classifier>javadoc</classifier>
50+
<classesDirectory>${basedir}/src/main/resources</classesDirectory>
51+
</configuration>
5052
</execution>
5153
</executions>
5254
</plugin>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This file is used to generate a FAKE jar which is needed by Sonatype
2+
to validate the artifact.
3+

0 commit comments

Comments
 (0)