Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
440 views
in Technique[技术] by (71.8m points)

java - Maven "shaded" JAR is prefixed with "original" in the file name

I'm using the "shade" Maven2 plugin to build a monolithic JAR with all Java dependencies bundled together. The relevant section in pom.xml is pretty straightforward:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <finalName>${project.artifactId}-${project.version}-SHADED</finalName>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>com.mypackage.MyClass</mainClass>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>

However, the build results are odd. It seems that TWO files are actually created by this Maven plugin:

myartifact-1.0.0-SHADED.jar  (zero bytes)
original-myartifact-1.0.0-SHADED.jar  (10 MB)

The JAR file with prefix "original" is properly built, and functions just fine. I suppose I could just rename it to strip off that prefix, and go on my merry way.

However, I very curious as to what may be going on here with the "shade" plugin. It looks like the "original" file is temporary working space type thing, intended to be renamed at the end of the process, and that final renaming simply doesn't complete. There's no obvious explanation for that, though (i.e. filesystem permissions, etc). Has anyone ever seen this before?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I know this question is old, but thought it was worth adding the following information.

I think the output originally desired by Steve is that given on this page of the maven-shade-plugin documentation.

<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...