Running uploadarchives deploys the war file to the nexus rather than jar file. I need the jar file as other projects depend on this project. I tried to use artifcats but it thorws an error
artifacts {
archives jar
}
A POM can not have multiple main artifacts. Already have MavenArtifact project:war:war:null, trying to add MavenArtifact project:jar:jar:null
I would assume your full buildfile contains the ‘war’ plugin
This says the the ONE built artifact is a war file and not a jar
According to maven each project can have one and ONLY one artifact (hence your error).
The question is then: what are you trying to accomplish? Do you want BOTH the jar and war on your nexus? Or just the jar? Why would you need a jar built from the same source as a war?
I my mind a war is an “application” a a jar is a “library”. A “library” is typically something you refer to from other libraries or applications and an application is never refered by anything. They are shipped somewhere. If I venture a guess it would seem that you have common code in your war that you want to publish on nexus. I would reccomend that this code is pulled out of the war project and into a separate project. This could be an excellent usecase of a multi-module build.
I would like some more details on your build to better answer the question.
I have the same problem, different usecase though. I also wonder if it’s possible to deploy the jar, when the war plugin is used or in the best case, both. The jar is needed to compile extensions which can be loaded into the running webapp.
A multi project build is possible but it adds complexity and I try to avoid that if there is not a really good reason.
My project generates a ~300k jar that I want to upload to artifactory as a release artifact. But I also generate a 21MB war that contains mostly dependencies; I see no reason to clutter Artifactory with 99% duplicate files.
Has anyone figured out how to upload a jar from a war project without rewriting my project into multiple submodules, which will play havoc with my project?