"Unattach" WAR artifact from lifecycle since it's is superseded by an RPM - maven

We have a multi-module Maven project who's primary artifact is a WAR. However our final build step is RPM packaging of that said WAR, and we really don't care about the WAR itself from a distributionManagement perspective. I would still like the JARS/source-jars uploaded to our Nexus repository, but it's just wasteful in terms of time/space to upload the WARs since no-one links agains that.
I would like to mark the WAR plugin as 'ignored' from a build life cycle point of view when going through the 'deploy' phase, since the RPM bundle itself is used.
I can't see any plugin configuration of the WAR plugin to avoid this, has anyone got any pointers?

Isn't that what the primaryArtifact property does? I've never used it, but I always assumed that's what it was for.

Related

bintray - publishing multi-module Gradle artifacts to JCenter

my project is organized as a Gradle multi-project build with five Java modules/sub-projects. When building them, it results in five different JAR artifacts.
Four of those artifacts contain helper classes or small, isolated portions of code doing very specific things (for example efficient graph search that is optimised towards my specific use case domain). Only one project is the "main" artifiact that makes sense to use in a standalone way, but all five artifacts are required for it to run.
I would like to make this core artifact available to users, and I have been successful in uploading all five artifacts to a Bintray account. When mirroring to JCenter, I have two concerns:
Do I have to actively link all 5 projects to JCenter, or is there a way to only expose the "core" artifact to the general public?
What does the "Is Pom Project" checkbox do? As I understand it, Gradle creates POM files for every Maven publication artifact, so this box should always be checked for Maven-style builds. Is this correct?
(potential duplicate that does not contain a solution apart from "I work at Bintray and I fixed it for you in our system!": Linking Bintray Package to JCenter)
Thanks!
- Gregor
I hope I can answer all.
Do I have to actively link all 5 projects to JCenter, or is there a way to only expose the "core" artifact to the general public?
As the other answer you have attached says, it is linked on path level, this means that if you include org/worldcubeassociation/tnoodle/lib-scrambles/ as the path, then only those modules will be linked to Jcenter.
What does the "Is Pom Project" checkbox do? As I understand it, Gradle creates POM files for every Maven publication artifact, so this box should always be checked for Maven-style builds. Is this correct?
Yes, you are correct. The POM file is created and uploaded. You can see the POM file in your path.
For more information you can always check the central repositories guide.

Maven plugin to inject svn info in prepare-package phase

I am already using maven-dependency-plugin to inject some externally built dependencies in the WAR artifact during the prepare-package phase. It works well because I don't want those dependencies to be part of the code base the WAR is made out of.
The next thing I would like is to do something like a file dump of svn info (which lists basic versioning info, such as the versioning branch, latest revision etc) and have that file included in my webapps dir so that it can be visible in the deployed application. Of course, I can write a script in half a dozen languages to do this but I would like to do it completely inside Maven. I have been successful thus far in my CI efforts to contain all the tasks in the universe of maven plugins, which is nice.
I am aware of maven-scm-plugin but I am not sure it does what I need.

What is the purpose of the pom.xml inside a jar's META-INF folder?

Typically, a maven built jar artifact will have it's pom included under META-INF. I recently noticed that the Spring jars don't have this. So, that causes me to wonder about the purpose of that pom.
It seems like maven retrieves the pom directly from the repository when it's doing things that require knowledge of the artifacts meta-data, e.g. when determining dependencies.
So, what's the embedded one for?
The Maven docs suggest two reasons for the pom in this location.
1) Merely for reference, as a convenience. As the docs say, it makes the artifact "self describing"
2) You can get at this information from within your application using Java. This enables the arfiact to auto-report it's version within the application.
http://maven.apache.org/guides/getting-started/index.html
The pom you will find in the repository is not necessarily the one used to build the artifact. It is aimed at the users of the artifact and can be customized when building your artifact.
The one included inside the artifact IS the one used to produce the artifact.
There are options to not have it included in the artifact.

Modern Maven Pom Templates

Every time I make a new proper project using Maven hosted on Github I have to go look at either one of my own old projects and copy the pom file or I go find a project that I think does a good job and copy there POM file. Then I have to go search and replace things like project name... etc.
Now Maven has a solution to this through archetypes but I have yet to see one that is modern enough such that it:
Uses the release plugin and deploys to SonaType Central Maven reop.
Connects to Github (meaning the scm connections and release plugin work do the right thing)
Makes all three jar artifacts (sources, javadoc, and regular jar)
I have contemplated make some giter8 templates but was hoping somebody already did something like this (most of the g8 templates are for sbt).
You can use com.jcabi:parent:pom which does exactly what you need and many more. It deploys to Sonatype, defines common dependencies with versions, pre-configures most popular plugins, and defines a few useful profiles.
This article explains more: Don't Repeat Yourself in Maven POMs; Use Jcabi-Parent
You could have a look at the parent pom released by Sonatype. It's intended to be used as a parent pom for projects that deploy to oss.sonatype.org (which may or may not be promoted to Maven Central).
When the sonatype-oss-release profile is enabled, it will ensure that sources and javadocs are built. It also includes an example of the <scm> pom element.
It turns out its incredible easy to create your own maven archetype.
Just make a generic project with stuff you like to use
In the project directory run mvn archetype:create-from-project
Generally Maven guesses the right things to make variable but if not you just edit the Velocity templates.
Install your archetype locally with mvn install
To use your new archetype: mvn archetype:generate -DarchetypeGroupId=com.mygroup -DarchetypeArtifactId=my-archetype
Now the only caveat is that there is not very good doc on the web that I could find on the archetype system. Like its unclear what variables you have available to you for Velocity (although most of them are obvious).
http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html

Maven and ibiblio

I searched a lot in apache documentation and ibiblio.org and I could not find a decent straight answer.
My questions:
When I download a jar using maven dependency (setup in pom), how can I be sure that the file does not change on the remote repository? for example, if I'm using log4j version 1.2.3, downloaded from ibiblio.org (or any other repo for that matter), how can I be sure I'm getting the exact same jar each time?
Does maven delete jars from the local repository? let's assume I'm not clearing the repository at all, will it fill up eventually? or does maven have some kind of mechanism to clear old jars?
In Maven conventions a released version like log4j 1.2.3 will never be changed. It will be left in your locale repository until you manually delete it. It can't be changed by anyone except for the admins on maven central, but i suppose they don't do such a stupid thing.
Furthermore the download by default is done from maven central (repo1.maven.org/maven2 instead of ibiblio).
One of the "tricks" in Maven is download an artifact (released) only once...that improved your build performance in contradiction to the SNAPSHOT dependencies.
You could configure your own repository, and point all your project poms at that. It's easy to configure your poms to use a different (private) repository, but I've never set one up myself. Doesn't seem too hard, other than managing it to keep all the needed artifacts available.

Resources