4
Problem:
When I create a JAR
for eclipse
it works smoothly, but I’m trying to enjoy the JAR
that the Maven
is creating and I realized that it does not perform, because my class main
is not in the Manifest
.
Use this setting on POM.XML
to inform my class Main
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>ClasseMain</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
When I use the mvn install
receiving:
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.app:ClasseMain:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 52, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
From what I understand this warning and referring to the code I posted above, but I cannot find a solution for the warning to disappear. And even reporting where class is Main
the JAR
does not run.
Doubt
If the code I am reporting on POM.XML
is incorrect to inform the class Main
What is the right one?
How to disappear with the WARNING
that appears whenever I make a mvn install
?
Interesting. I noticed that mvn
package
orinstall
generate aJAR
in the briefcasetarget
. Use.
or/
along those lines<mainClass>com.aplication.ClasseMain</mainClass>
also has no influence, theJAR
generated works. The strange thing is that myJARs
which use as dependency are not within theJAR
generated. How to put them there usingMaven
?– noNihongo
hi @Eduardobentorochajunior responded with an example from
maven-assembly-plugin
– João Paraná
Another alternative is to use the
maven-dependency-plugin
to copy the files to the desired place.– João Paraná
The
maven-assembly-plugin
works, but it unpacks dependencies and includes theJAR
. The process I need to do is simply add the.jar
of the dependencies the eclipse does it. Thatmaven-dependency-plugin
do it? (I’ll test)– noNihongo
use the Maven-dependency-plugin then
– João Paraná
João Paraná or @Eduardobrj, know how to run the
maven-dependency-plugin
straight through the eclipse interface instead of using command line to domvn assembly:assembly
?– Math
@Math, I might be talking nonsense, using
mvn clean
and thenmvn install
, automatically the it calls themaven-dependency-plugin
. For direct use via eclipse interface,Botão direito no projeto
>Run
>Depois tem as opções mvn
and if you need to customize goRun Configurations
.– noNihongo