how to make maven war:explode do not pack a jar file - maven

I'm new to maven.
I'm now working on a multi module maven project, when i use maven war:exploded ,it will packaging classes files to WEB-INF/lib/***SNAPSHOT.jar.
Is there any way to leave the classes files under WEB-INF/classes , for when java file changes, there is no need to replace the whole jar file?
Thanks

Related

Include the bytecode of a JAR file in a gradle library vs. just adding it as a dependency

If I add a JAR file to a gradle project's depenencies, the code compiles just fine, but after publishing to maven (publishToMavenLocal), the classes from the JAR are not found.
Obviously, this is because the jar is added as a "dependency" and not part of the project itself. Is there a way to get the contents of the JAR file to merge into the library? Do I need to make a separate maven repo for each JAR?
You can always try to create a fat jar which includes dependencies. You can follow the instructions provided here https://www.baeldung.com/gradle-fat-jar

Compile a jar during Maven build then package as ear from single pom.xml?

I have a maven project currently structured that has to build a jar first from some source files, then create an ear file containing that jar along with some other xml resources. The way I do it at the moment is by building the jar seperate in a 'child' pom.xml then at the root of the project folder I have a parent pom that does the ear packaging.
I know it isn't ideal, but I what to be able to compile the jar and then package it into an ear all with just one pom.xml file. Any ideas on how to do this?

How do I build an exploded WAR in a multi-module Maven project and also include sibling JAR files in its WEB-INF/lib directory?

I’m using Maven 3.3.3 with the Maven WAR 2.6 plugin. I have a multi module project with both JAR and WAR projects within it. My WAR projects depend on my JAR projects, however, I do not want to package my WAR files, opting instead to keep them in an exploded form. So I tried running this command
/usr/local/apache-maven-3.3.3/bin/mvn -B -f /home/jboss/.jenkins/jobs/subco/workspace/pom.xml -B clean prepare-package war:exploded -DskipTests -T 3
Although this keeps my WAR exploded, the JAR projects do not get included in my web application’s target/myproject/WEB-INF/lib directory. Instead what is included are empty directories where my JAR files would have been, for instance
.jenkins/jobs/subco/workspace/myproject/target/myproject/WEB-INF/lib/child-jar-module-2.0.0-SNAPSHOT.jar/
How can I keep an exploded WAR, include my JAR files, and do it all from the command line (as opposed to creating a custom profile in my parent pom to do it for me)?
Edit: If you think this is a duplicate of another one, notice the part of my question where i point out that empty directories are generated when using the "prepare-package" phase. I don't want that.

How to add a xml a file as dependency using gradle?

I have a project build on gradle and it has a directory src/main/dist/deploy. In deploy folder there is a xml file. This xml file i want to add as a dependency in the jar file which my build.gradle is generating. This jar i am adding in the lib folder of another project that has a dependency on my gradle project. The other project is built using ant. When classes bundled in gradle jar are loaded from ant project they are unable to read that xml file from the gradle jar.
The standard java plugin does not look in src/main/dist/deploy for resources.
You should either move the xml file into java plugin's standard resource folder src/main/resources, or add the dist/deploy folder to your main sourceSet's resource list.

Maven update contents of an EAR file

I have an EAR file which I want to update. I do this in Ant by unzipping the EAR and then the JAR, replacing a few files and then repackaging it.
I am trying the same with Maven but with little success and it is also confusing.
So far I have done
1) installing the EAR file in the local maven repository
2) unpack it
3) Replace the file I need
Now I am not sure how to get back the new EAR file. Everything is in the repository.
From my understanding, the EAR plugin packs everything in the ejb, war folders and spits out the ear. But since I directly got the EAR file, I do not have any project per se.
Any suggestions on this?
Also is there a good tutorial on Maven?
Thanks,
You should probably perform the following steps, using a "blank" Maven project and assuming the EAR file is already inside a repository (pushed by another project/tool):
use the dependency:unpack mojo to get and unpack (inside the /target/ folder of your project) the EAR
modify the contents
use the assembly plugin to repack that EAR file
Then do what you need to do with that new EAR file.
A "blank" Maven project would mean that it will not act as a usual project (compile sources, package output...), but rather serve to manipulate existing artifacts through specific plugins.

Resources