Excluding JAR Files From the EAR using maven - maven

My EAR includes 8 JAR files which are in the root of my EAR. I want to delete two of them for my final deployment EAR package.
I was trying do this as it is described here:
https://maven.apache.org/plugins/maven-ear-plugin/examples/excluding-files-from-ear.html
But seem not to work.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>test1.jar,test2.jar</packagingExcludes>
</configuration>
...
</plugin>

Related

Spring Boot 2.2.1 Create two jar's while Build [duplicate]

This question already has answers here:
Why spring boot generates jar or war file with .original extension?
(2 answers)
Closed 3 years ago.
I am working on Spring boot version 2.2.1.RELEASE.While building my project two jar's will created having types executable jar file and original file as given below
The reason for this is
Maven first builds my project and packages my classes and
resources into a jar (${artifactId}.jar) file.
Then, repackaging happens. In this goal, all the dependencies
mentioned in the pom.xml are packaged inside a new WAR
(${artifactId}.jar) and the previously generated war is renamed to
${artifactId}.jar.original.
Pom.xml
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.data.MainService</mainClass>
</configuration>
</plugin>
</plugins>
</build>
How can we avoid to create ORIGINAL File type jar file.
Is there any disable /excluding technique available in maven.
Am also tried following <build>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.data.MainService</mainClass>
</configuration>
</plugin>
</plugins>
</build>
As per the implementation jar.original is expected. Nothing to worry about.
Re packaging creates new jar file and renames old one to jar.original
https://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins.html#build-tool-plugins-repackage-implementation

How to place output Jar and War files in another specified folder(it may be outside of the project)?

i want to place output jar or war in another separate folder which should contain only jar or war file. i.e folder may be outside of the project. is that possible?
Although generally it's not a good idea to deviate from Maven conventions, you can use outputDirectory parameter in maven-jar-plugin to specify a directory other than ${project.build.directory}
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<outputDirectory>path/to/your/folder</outputDirectory>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>

Including a Maven product from different directory into project directoy

My question I have a project in x directory and another maven project in x/y directory. Now how can I get the jar files be generated for a project in x directory from a project in y directory
You can use the jar-plugin within a project's pom.xml to modify the location of the output jar -
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<outputDirectory>/x/y</outputDirectory> <!-- specify the relative desired path here -->
</configuration>
</plugin>
</plugins>
</build>

I don't want to include external jar in my maven war

I don't want to include external jars when I build a war.What should I do?
Though not sure about why are you thinking to exclude the jar files, but yes you can do that if you are using maven-war-plugin
This will work out
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
</configuration>
</plugin>
</plugins>
</build>
This a whole bunch of configuration plugin that excludes all .jar files.
This source explains about that and even regex patterns that can be used.

How to add libs to Classpath in my manifest file via maven?

I using Maven 3 + hudson + artifacotory
I used the following
<artifactId>maven-war-plugin</artifactId> <addClasspath>true</addClasspath> <classpathPrefix>WEB-INF/lib/</classpathPrefix> </manifest>
and I got the result as.....
WEB-INF/lib/gwt-servlet-2.4.0.jar WEB-INF/lib/gwt-user-2.4
.0.jar WEB-INF/lib/validation-api-1.0.0.GA.jar WEB-INF/lib/validation
-api-1.0.0.GA-sources.jar WEB-INF/lib/log4j-1.2.16.jar WEB-INF/lib/co
mmons-lang-2.6.jar
I am find well and good.
My one more requirement is,
I need to add/append two more libs with the above manifest file. see below
/u01/app/TimesTen/tt1121/lib/orai18n.jar /u01/app/TimesTen/tt1121/lib/ttjdbc5.jar
So how can add/append this is to my Manifest, so that above 3 will be included?
maven war plugin as well as maven jar plugin use maven archiver which in turn allows you to specify your own manifest file. According to the documentation,
The content of your own manifest file will be merged with the entries
generated by Maven Archiver.
Cut/pasting the relevant pom snippet from the above link for ready reference
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
...
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
...
</plugin>
</plugins>
</build>
...
</project>
So you could add the additional entries in this custom MANIFEST.MF and use it in conjunction with the maven war plugin.

Resources