maven-shade-plugin output with shadedArtifactAttached false overwritten by install

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

maven-shade-plugin output with shadedArtifactAttached false overwritten by install

Karin Colsman
Dear list members,

I am having a problem with deploying jar files created by the maven-shade-plugin. It used to work, but it has stopped working. From my research the problem seems to be that the install step is overwriting the shaded jar.

Please cc me when replying, because I haven't subscribed to the list.

Thank you very much for your time!

Now all the tl;dr details - please let me know if you need more.

If I use the following setting:

    <shadedArtifactAttached>true</shadedArtifactAttached>

It will create a fat jar for me, but If I change that to

    <shadedArtifactAttached>false</shadedArtifactAttached>

installing/deploying will remove the dependencies and the manifest entry for the main class.

I don't want to use the "true" setting, because the file rename will break all my tooling that depends on a generic script that will a deployed artifact via CURL.

So, when I run

    $ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade

I get the correct files: ontology-merger-0.3.31.jar (big file) and original-ontology-merger-0.3.31 (small file)

when I run

    $ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade install

the install step will trash the shaded jar. I am assuming that this happens because it's running the maven-jar-plugin over it, although I don't mention the maven-jar-plugin anywhere in my pom.xml. I have no idea how to switch this off.

Important bits from the log:

[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar with C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31-shaded.jar
[INFO] Dependency-reduced POM written at: C:\dev\allotrope\source\ontology-qa-tools\merger\dependency-reduced-pom.xml
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ ontology-merger ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ ontology-merger ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ ontology-merger ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 30 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ ontology-merger ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ ontology-merger ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ ontology-merger ---
[INFO] Building jar: C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ontology-merger ---
[INFO] Installing C:\dev\allotrope\source\ontology-qa-tools\merger\target\ontology-merger-0.3.31.jar to C:\Users\User\.m2\repository\com\osthus\ontology-merger\0.3.31\ontology-merger-0.3.31.jar
[INFO] Installing C:\dev\allotrope\source\ontology-qa-tools\merger\dependency-reduced-pom.xml to C:\Users\User\.m2\repository\com\osthus\ontology-merger\0.3.31\ontology-merger-0.3.31.pom

The section in my pom.xml currently looks like this:

                                <plugin>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-shade-plugin</artifactId>
                                        <version>3.2.3</version>
                                        <configuration>
                                                <shadedArtifactAttached>true</shadedArtifactAttached>
                                                <transformers>
                                                        <transformer
                                                                implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                                                <mainClass>com.osthus.ontology_merger.MergerMain</mainClass>
                                                                <manifestEntries>
                                                                        <Main-Class>com.osthus.ontology_merger.MergerMain</Main-Class>
                                                                </manifestEntries>
                                                        </transformer>
                                                        <transformer
                                                                implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                                        <transformer
                                                                implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                                                        <transformer
                                                                implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                                                                <addHeader>false</addHeader>
                                                        </transformer>
                                                </transformers>
                                                <filters>
                                                        <filter>
                                                                <artifact>*:*</artifact>
                                                                <excludes>
                                                                        <!-- Some jars are signed but shading breaks that. Don't include
                                                                                signing files. -->
                                                                        <exclude>META-INF/*.SF</exclude>
                                                                        <exclude>META-INF/*.DSA</exclude>
                                                                        <exclude>META-INF/*.RSA</exclude>
                                                                </excludes>
                                                        </filter>
                                                </filters>
                                        </configuration>


My various fix attempts are in this branch:

https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/tree/deployment-test

Path to the pom.xml:

https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/blob/deployment-test/merger/pom.xml


A bit of history:

My deployment that had been working for years without a hitch already broke recently and I fixed it last month via

https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/commit/7080d16179c2ccf7ab47208716b1bf1b3a05be29

and

https://gitlab.com/allotrope-open-source/ontology-qa-tools/-/commit/0d231d691ffd48347e34f9da9373d092939e69e2

where I had to add some boilerplate to the pom.xml files and change

    $ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean deploy

to

    $ mvn -s ../.m2/settings.xml --batch-mode --errors --fail-at-end --show-version clean package shade:shade deploy


Thank again for your time and kind regards

Karin Colsman


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]