maven's pom.xml ordering - maven

I want to checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file. can you please provide me a sample pom.xml file in which all these tasks have been performed in the above given ordering.

You can't do that in the POM cause Maven is not Ant...you can do that by using Jenkins/Hudson or any other CI solution.

Jenkins+Hudson can do this... But It don't mean that it cannot be done in Pom.xml. We can also use combination of ant scripts in pom.xml and we can use Maven AntRun Plugin to execute them. So by maven we can checkout code from svn, then compile it and then copy it to a remote location and then deploy the war file.
Check out this Usage Page

Related

Location of POM file in multi-module project for use in Maven Deploy Plugin

I have a multi-module Gradle project (which generates 3 artifacts per module, the sources, javadoc, and main jar). I need to generate a .pom file for my project for use with the Maven Deploy Plugin which is installed on an image that Gitlab CI uses. I have a (WIP) script which generates a .pom file with gradle, but I'm unsure of exactly where or how many .pom files I need for all of my modules.
Questions:
Where exactly should I be generating a .pom file(s) so that the
Maven Deploy Plugin can see it when I run mvn deploy:deploy in the
Gitlab yaml file?
Do I need a separate .pom file for each group of module artifacts?
Any help would be appreciated! Especially some sort of example of someone generating a .pom file with Gradle and then deploying with the Gitlab CI.

How to run a maven plugin without a POM in Jenkins?

I have a plugin which can run either using a pom.xml or without (depends upon the version of the artifact we're building: new versions go without a pom. Strange, I know).
I want to have that plugin run in Jenkins.
But when creating a maven project, I have to set a pom (or as a default, Jenkins suppose there is one in the base folder given).
Question: Is it possible to configure Jenkins to not use a pom when there is none?
As per my comment, you should use a Jenkins freestyle project build in this case, in order to have more flexibility and avoid the default assumptions of a Jenkins Maven build.
In such a build, you can then configure a build step executing a shell or a Windows command (depending on the Jenkins server OS).
Indeed, in the Jenkins Maven build, a pom file is always required, as mentioned in the help support of the Configuration > Build > Root Pom entry
If your workspace has the top-level pom.xml in somewhere other than the 1st module's root directory, specify the path (relative to the module root) here, such as parent/pom.xml.
If left empty, defaults to pom.xml

How to add dependency to my pom.xml?

I want to use https://code.google.com/p/droidpersistence/source/checkout but I don't know how add to my pom.xml..
The link you provided specifies a place you can download some code, using Subversion:
svn checkout http://droidpersistence.googlecode.com/svn/trunk/ droidpersistence-read-only
So run that command, and it will download the code. That particular code is designed to be built with ant, instead of maven. You need to write a little pom.xml file for it, so that when you build it on your computer with "mvn clean install", maven will generate a .jar file (the artifact), and put it in your local maven repository (.m2 directory). Then add a dependency on that jar to your pom file.
In general, to add a dependency to your pom using the latest version of IntelliJ Idea (12.1.6), click somewhere in your pom file, and press ALT-INSERT, then choose "dependency".
Hope this helps!

Maven: Deploying a jar/war with built in pom.xml file

I don't have a Maven project. What I have is a jar with the pom.xml embedded in the file. When I deploy this via the Artifactory GUI, Artifactory finds the pom and deploys it with the jar. It even recognizes the groupId, artifactId, and version.
When I try using mvn deploy:deploy-file it fails. If I extract the pom, and run mvn deploy:deploy-file with the -DpomFile=pom.xml, it works. Is there a way of deploying this jar with the embedded pom via the Maven command line? Or, do I need to extract the pom.xml first?
I have not heard of the possibility to specify the pom file from archive. I think it is unlikely to be an option, because Maven itself is just a light-weight program, which runs with plugins; and it needs some configurations to run with; and all references to plugins to be used are in those files.
Consider writing an Ant script that will extract the file, run mvn deploy:deploy-file -DpomFile=pom.xml and then delete the file.
The solution looks not very nice, I know, but it should help.
This is an Artifactory feature and not standard Maven behaviour.
Keep in mind that, for example, if you use dependency:unpack-dependencies or the assembly plugin to create some sort of über jar there would be multiple pom.xml files within the jar under the /META-INF/ path so it would be very difficult to select which pom was the true pom.

Access Maven build properties in Jenkins post-build script to retrieve deployed artifact

I've got a Maven project that Jenkins builds and deploys to a remote repository. I then need to copy the deployed .war to an external location. I've been trying to do this with a post-build shell script but I don't see any way to get the build information from maven (for example, the URL of the deployed artifact). Is there a way to get it, or a way to do this that's more integrated into maven? I can calculate the deployment path using Jenkins build parameters but it seems like a hack.
Thanks,
Steve
After a maven build you should always find the build artifact at
target/<artifactId>-<version>.<packaging>
You can access this path within the maven pom.xml by using the maven properties (see pom reference)
${project.build.directory}/${project.artifactId}-${project.version}.${project.packaging}
To copy the artifact to another location after the build you can use several approaches described e.g. in this thread.

Resources