Skip to content

Conversation

@dadoonet
Copy link
Contributor

Sonatype rule sources-staging force to provide a *-sources.jar artifact.

This PR generates the source jar even if there is no related java code by considering the pom.xml file as a source file.

We could set this globally on the project but I prefer being cautious here and just add this to the projects which are not generating source files archive for now.

When you run it on distribution packages or site-example plugin, you now get:

[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] Building jar: /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/plugins/site-example/target/site-example-2.4.0-SNAPSHOT-sources.jar

Was previously:

[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] No sources in project. Archive not created.

Sonatype rule `sources-staging` force to provide a `*-sources.jar` artifact.

This PR generates the source jar even if there is no related java code by considering the `pom.xml` file as a source file.

We could set this globally on the project but I prefer being cautious here and just add this to the projects which are not generating source files archive for now.

When you run it on distribution packages or site-example plugin, you now get:

```
[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] Building jar: /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/plugins/site-example/target/site-example-2.4.0-SNAPSHOT-sources.jar
```

Was previously:

```
[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] No sources in project. Archive not created.
```
@dadoonet dadoonet self-assigned this May 17, 2016
@dadoonet dadoonet added review :Delivery/Build Build or test infrastructure v2.4.0 v2.3.3 labels May 17, 2016
@clintongormley
Copy link
Contributor

LGTM

dadoonet added a commit that referenced this pull request May 17, 2016
Sonatype rule `sources-staging` force to provide a `*-sources.jar` artifact.

This PR generates the source jar even if there is no related java code by considering the `pom.xml` file as a source file.

We could set this globally on the project but I prefer being cautious here and just add this to the projects which are not generating source files archive for now.

When you run it on distribution packages or site-example plugin, you now get:

```
[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] Building jar: /Users/dpilato/Documents/Elasticsearch/dev/es-2x/elasticsearch/plugins/site-example/target/site-example-2.4.0-SNAPSHOT-sources.jar
```

Was previously:

```
[INFO] --- maven-source-plugin:2.4:jar (attach-sources) @ site-example ---
[INFO] No sources in project. Archive not created.
```

Backport of #18396 in 2.3 branch

(cherry picked from commit 9ec001b)
@dadoonet dadoonet merged commit 9ec001b into elastic:2.x May 17, 2016
@dadoonet dadoonet deleted the maven/attach-source branch May 17, 2016 10:12
@dadoonet dadoonet removed the review label May 17, 2016
dadoonet added a commit to dadoonet/elasticsearch that referenced this pull request May 17, 2016
Follow up for elastic#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
```
dadoonet added a commit that referenced this pull request May 17, 2016
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)
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team v2.3.3 v2.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants