How to publish hadoop-dist-*.tar.gz with maven - maven

We use maven to publish hadoop artifacts to an Artifactory installation. By default, the jars are published, but we'd also like the hadoop-dist tarball published.
To publish the JARs, we run something like this:
mvn -e 'clean package deploy' -Pdist -DskipTests -Dtar -Dmaven.javadoc.skip
This does build the hadoop-dist tarball, but doesn't publish it.
What extra args do we need to get the dist tarball published too?
Updated: Dist profile included below, as per request in the comments.
<profile>
<id>dist</id>
<!-- Profile for generating all maven artifacts and documentation. -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<!-- build aggregate javadoc in parent only -->
<id>default-cli</id>
<goals>
<goal>aggregate</goal>
</goals>
<configuration>
<overview>hadoop-common-project/hadoop-common/src/main/java/overview.html</overview>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

Related

is it possible to version and deploy a configuration file to nexus via maven commands

I am working on a java project and I would like to version and store a configuration file on nexus. Lets assume the file structure of java project is as below.
src/
conf/application.config
pom.xml
Is it possible to deploy application.config file to nexus when I run mvn clean install. After each build I expect an application artifact and a configuration artifact to be deployed to nexus. Is there any maven plugin for this purpose.
I manged to deploy file with maven-deploy-plugin.
http://maven.apache.org/plugins/maven-deploy-plugin/usage.html
You can find an example below.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-file</id>
<!-- change to deploy-->
<phase>install</phase>
<goals>
<goal>deploy-file</goal>
</goals>
</execution>
</executions>
<configuration>
<file>app.properties</file>
<repositoryId>stack.example.release</repositoryId>
<url>http://nexusserver/nexus/content/repositories/releases/</url>
<groupId>com.stack.example.config</groupId>
<artifactId>app</artifactId>
<packaging>properties</packaging>
<version>1.0.0</version>
</configuration>
</plugin>
</plugins>
</build>

How to create a private JAR in a local subdirectory which I have designated as an additional repository?

In a subdirectory under a project, I have a library module of code I write and maintain that must be shared with other modules in the larger project. For convenience, it's developed simultaneously alongside all the modules consuming it.
project
libs
module-A
module-B
module-N
library-module
For complicated reasons imposed by how our build is done after it leaves our hands, we don't want it deployed to the build host's local Maven repository (~/.m2/repository). Instead, we want it in a subdirectory local to the project, here libs.
From the command line, I know the following will put it into the local Maven repository, but I don't want to do this from the command line and I don't want the result to go to the local Maven repository. I want this to happen when mvn install is run by the build system in the library-module subdirectory.
mvn install:install-file -Dfile=your-artifact-1.0.jar \
[-DpomFile=your-pom.xml] \
[-Dsources=src.jar] \
[-Djavadoc=apidocs.jar] \
[-DgroupId=org.some.group] \
[-DartifactId=your-artifact] \
[-Dversion=1.0] \
[-Dpackaging=jar] \
[-Dclassifier=sources] \
[-DgeneratePom=true] \
[-DcreateChecksum=true]
(Note that the answer I'm looking for would not be IDE-dependent.)
To meet the provided requirements, two configuration steps are then required:
Disable the default artifact installation to the local repository, via the skip option of the Maven Install Plugin
Configure the install-file goal within the POM in order to have it as part of your build (hence no need to invoke it manually from command line)
The following configuration would provide it:
<properties>
<library.repository.folder>../libs</library.repository.folder>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>install-artifact</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>${project.packaging}</packaging>
<file>${project.build.directory}/${project.build.finalName}.${project.packaging}</file>
<localRepositoryPath>${library.repository.folder}</localRepositoryPath>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Please note the library.repository.folder property used to point to the desired target lib folder (to change in case of different path). The configuration provided above makes use of standard maven properties (for project coordinates and packaging), but you can change them (or hard-code real values) as required.
Also note that the install-file goal will recreate under the lib folder the same folders structure as in the local repository (lib\groupId\artifactId\version\file.jar). If you instead would like to have the file straight under the lib folder (lib\file.jar) you could then move to the following configuration:
<properties>
<library.repository.folder>../libs</library.repository.folder>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>${library.repository.folder}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
This time we are not using the install-file goal but rather the jar goal of the Maven Jar Plugin to place the packaged artifact directly to the lib folder (instead of the standard target folder) and during the package phase (not install).
If by any reason you want to keep the final artifact in the target folder AND have it straight copied to the lib folder (no maven folders hierarchy) AND during the install phase, then you could move to the following configuration:
<properties>
<library.repository.folder>../libs</library.repository.folder>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>re-package-into-lib</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<outputDirectory>${library.repository.folder}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

How does maven deploy snapshot without dependencies with maven-assembly-plugin

I am using mvn release-plugin and assembly-plugin to deploy jar with dependency. It works fine, when I use it with mvn release. It creates two files: normal XXX.jar and XXX.jar-with-dependencies.jar and deploys them both.
But I need also deploy snapshot to another repository by using mvn deploy. In this repository I only need the XXX.jar without dependencies.
So I hope that I could use mvn deploy to deploy snapshot version without dependencies with followed setting.
POM.xml setting:
...
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>install</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
...
PS: mvn clean install deploy will be called by jenkins scm pulling schedule every morning.
Artifacts produced by maven-assmbly-plugin are automatically attached to the project and hence are deployed when you call mvn deploy.
What you can do is to define a profile (say 'with-dependencies') where you put the assembly plugin execution. In this case if you call mvn deploy it will build a -SNAPSHOT version and push it to the snapshot repository and for the release you will have to call mvn release:prepare release:perform -Pwith-dependencies
<profile>
<id>with-dependencies</id>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>install</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</profile>

Jenkins "Post Build Action" to deploy zip on Maven repository

I Have recently started using Jenkins and currently using version 1.492. I have a Maven module project which produces a Jar and a Zip files which I want to deploy to a Nexus Maven repository.
When I build my project locally I get the message :
Installing PROJECT_DIR/target/groupID/projectId-version.jar to LOCAL_REPO/ groupID/projectId-version.jar
Installing PROJECT_DIR /groupID/projectId.zip to LOCAL_REPO/ groupID/projectId/version/ projectId-version-classifier.zip
Using the "Post Build Action" Deploy artifacts to Maven repository. On the Jenkins build logs I can see my jar is deployed but nothing about my zip.
Is there a specific config to fix it?
Configure your project to attach additional zip artifact.
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>some file</file>
<type>extension of your file </type>
<classifier>optional</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Maven is not using failsafe plugin for integration tests

When I run mvn clean install, for the integration-test phase it does not use the failsafe plugin.
However if i explicilty call the plugin to run the integration test, it works (mvn failsafe:integration-test).
How can I make maven use the failsafe plugin when I run mvn clean install during the integration-test phase?
Quote from official documentation:
To use the Failsafe Plugin, you need to add the following configuration
to your pom.xml
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.11</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
Is this what you looking for?

Resources