maven deploy - only upload ear file to nexus - maven

I have a maven project with a couple of modules.
When I use the maven deploy plugin, all the modules are uploaded to my local Nexus server.
I want the deploy to only upload the ear file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>

You need to use this goal: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html
deploy:deploy-file is used to install a single artifact along with its pom. In that case the artifact information can be taken from an optionally specified pomFile, but can be completed/overriden using the command line.
You can find an example of it being used on the usage page.

Related

What is the best place for JavaDoc files in a Maven project using Tomcat?

I am regularly deploying a Maven project to a Tomcat server, using Travis CI. My project is a web app, so I have configured my pom.xml for building a WAR file, instead of a JAR:
...
<packaging>war</packaging>
...
With Maven, I can generate a directory containing all the JavaDoc files for my project; Maven puts them in the target/site/apidocs directory. But then, when I deploy my project, Travis doesn't perform any mvn site phase so I don't have my JavaDocs on the server.
Should I edit my pom.xml so that Maven puts the JavaDoc files somewhere in the src directory (instead of target) or is there a way to package the JavaDoc files together with the WAR file? I thought that I could create a docs/ directory inside src/main/webapp/. Specifically: is it "good practice" to generate my JavaDoc in src instead of target? if not, how can I have a WAR file containing my JavaDoc?
What would you suggest is the best thing to do?
I already know how to generate a standalone JAR containing my JavaDoc files (see here), but this is not what I'm looking for.
Use the site plugin https://maven.apache.org/plugins/maven-site-plugin/ and the javdoc plugin https://maven.apache.org/plugins/maven-javadoc-plugin/usage.html.
Add the following to your pom.xml
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<links>
<link>http://commons.apache.org/lang/api</link>
<link>http://java.sun.com/j2se/1.5.0/docs/api</link>
<link>http://this-one-will-not-work</link>
</links>
</configuration>
</plugin>
</plugins>
</reporting>
then mvn site:site your documentation will be in target/site you can also deploy it.

how to sharing a karaf feature without a maven repository?

I need to share a feature with someone with whom I don't share a repository. Is it a good idea to just zip the maven artifact directory directory from my local maven repository and send it over ?
the directory has feature xml pom and jars. Is there a better way of doing this short of sharing a common central repository ?
For that i would use a KAR File, it's one of the recommended ways to provision karaf features, it will package your bundle, the feature and all dependencies in one archive there are two ways to generate kar files:
First one, you can generate using karaf itself:
karaf#root()> kar:create your-feature
The seconde one, you can generate the kar file using the following maven plugin with your project as a kar packaging.
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>4.0.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Then you can just drop the kar archive at the deploy folder, or install it using the kar:install command.
For more informations check https://karaf.apache.org/manual/latest/kar

How to move my own archive file from Jenkins system to artifactory

Thanks in advance! I am new to Jenkins and Maven. Please clarify my query for better understanding.
After the build war getting deployed from Jenkins system to Artifactory location (created under the tags <distributionManagement>/<snapshotRepository> in parent pom.xml). How this is happening without any scripts configured in Jenkins?
Can I do the same for my own archive file to place in Artifactory from Jenkins system after the build? I exposed some jars and getting archived in Jenkins system during the build and expecting same to be placed in Artifactory after the build same as how war is getting placed in Artifactory.
PLugin details for deploy:
I have many webapps and parent/super pom.xml.All wars are getting deployed in artifactory repository.Now looking for solution to deploy common folder also (ProvidedDependencies_${version} - Created during build time) .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>artifactory</repositoryId>
<generatePom>true</generatePom>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>/ProvidedDependencies_${version}</file>
</configuration>
</plugin>
Invoking mvn deploy deploys the artifact(s) that has (or have) been built during the current run to your local repository, Artifactory in your case. See Introduction to the Build Lifecycle.
A Jenkins Maven 2/3 project or a Free-style software project with an appropriate build step can be configured to invoke mvn deploy.

Maven JavaDoc Plugin by providing Source path

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<sourcepath>${svn url}/src/main/java</sourcepath>
</configuration>
</plugin>
Doesn't generate Javadoc while running goal as maven javadoc:javadoc because the source is not available in a maven project. Can I pass the svn url directly?
The source code for which i want to generate javadoc is not maven project.so externally i had created maven project ,in that project i need to generate javadoc
Firstly , you do NOT need a maven project to generate source code for any project whatsoever.
As the source is not available in maven project.I am passing directly svn url
Why are you passing the SVN url here ? Since it is now a maven project, simply specify the path to the source folder of the project ( which I believe will be ${base.dir}/src/main/java )

Generate javadoc in maven and then upload via scp?

I have Maven javadoc plugin working nicely right now, but I do not know how to add it to the remote directory via scp.
How do I transfer the javadoc files via scp, but AFTER they have been generated? Can this automatically happen when I call site:site?
Thanks!
maven-javadoc-plugin doesn't attach to any phase/goal by default, you need configure it manually in pom.xml.
See Generate Javadocs As Part Of Project Reports:
To generate javadocs as part of the site generation, you should add the Javadoc Plugin in the section of your pom:
<project>
...
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<configuration>
...
</configuration>
</plugin>
</plugins>
...
</reporting>
...
</project>
When you execute mvn site, the javadocs will be generated and included in the generated site. A link to the javadocs will be added in the Project Reports menu.
Alternatively, if you use maven-release-plugin, javadoc generation (and upload) is automatically handled by default, see here:
The following delvierables are created and deployed to local and remoted repositories after the execution of the release:perform goal has finished.
artifact id-version.jar
The binaries for the current release of the project.
artifact id-version-javadoc.jar
The javadoc explaining the current functionality of the classes within the current release.
artifact id-version-source.jar
The source code revisions used to build the current release of the project.
artifact id-version.pom
The contents of the pom.xml file used to create the current release of the project.
If you want to attach javadoc generation to some phase/goal other than site, check out How to deploy Javadoc jar file?

Resources