Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find jar if classifier is used #10

Closed
galvanopus opened this issue Jan 24, 2016 · 5 comments
Closed

Cannot find jar if classifier is used #10

galvanopus opened this issue Jan 24, 2016 · 5 comments

Comments

@galvanopus
Copy link

Create sample maven project:

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DgroupId=com.example.excelsior -DartifactId=sample-application

Add classifier and excelsior-jet to pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.excelsior</groupId>
    <artifactId>sample-application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>sample-application</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <classifier>classifier</classifier>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.excelsiorjet</groupId>
                <artifactId>excelsior-jet-maven-plugin</artifactId>
                <version>0.3.0</version>
                <configuration>
                    <mainClass>com.example.excelsior.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Build:

mvn clean jet:build

...
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ sample-application ---
[INFO] Building jar: C:\Development\com.example.excelsior\sample-application\target\sample-application-1.0-SNAPSHOT-classifier.jar
[INFO]
[INFO] <<< excelsior-jet-maven-plugin:0.3.0:build (default-cli) < package @ sample-application <<<
[INFO]
[INFO] --- excelsior-jet-maven-plugin:0.3.0:build (default-cli) @ sample-application ---
[ERROR] Jar C:\Development\com.example.excelsior\sample-application\target\sample-application-1.0-SNAPSHOT.jar was not found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.673 s
[INFO] Finished at: 2016-01-24T16:48:12+03:00
[INFO] Final Memory: 19M/294M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.excelsiorjet:excelsior-jet-maven-plugin:0.3.0:build (default-cli) on project sample-application: Jar C:\Development\com.example.excelsior\sample-application\target\sample-application-1.0-SNAPSHOT.jar was not found -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
@pjBooms
Copy link
Contributor

pjBooms commented Jan 25, 2016

Thank you for the bug report.

As a workaround you may specify <mainJar> plugin parameter referencing target jar artifact.

@galvanopus
Copy link
Author

Yep, <mainJar>${project.build.directory}\${project.artifactId}-${project.version}-classifier.jar</mainJar> makes a deal.

pjBooms pushed a commit that referenced this issue Jan 29, 2016
@pjBooms
Copy link
Contributor

pjBooms commented Feb 2, 2016

I have corrected the error message explicitly referring <mainJar> plugin parameter for this case.
Applying the classifier automatically is not so easy to implement because it is a parameter of maven-jar-plugin. Moreover, you can build the jar with another plugin and that plugin can have its own configuration parameters for the final name.

And I did not find a regular way to know the exact name of the target artifact of the build from Maven configuration environment. If you find such a way, please let me know.

@pjBooms pjBooms closed this as completed Feb 2, 2016
@galvanopus
Copy link
Author

Thank you. I am using the following configuration right now:

<properties>
    <maven.jar.classifier>external-lib-${external-lib.version}</maven.jar.classifier>
</properties>
...
<configuration>
    <mainClass>com.example.excelsior.App</mainClass>
    <mainJar>${project.build.directory}\${project.build.finalName}-${maven.jar.classifier}.jar</mainJar>
    <outputName>${project.build.finalName}-${maven.jar.classifier}</outputName>
</configuration>

@galvanopus
Copy link
Author

It seems it is easier to use <finalName> instead of classifier. In such case plugin does not need <mainJar> configuration:

<build>
    <finalName>${project.artifactId}-${project.version}-external-lib-${external-lib.version}</finalName>
</build>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants