Take post-build action maven - maven

I want to sftp the binary generated after build (if build is successful) is completed to a different server using maven. Please suggest how this can be done?
I want to edit pom.xml to achieve this.
Build system is maven. Please not that file is to be copied on different server
Thanks

You typically described a perfect use case for the Wagon Plugin.

Related

Need to run ReadyAPI using maven project with jenkins as CICD approach

Run the ReadyAPI project using maven with help of jenkins.
I have already created a regression suite in readyAPI as xml format.
Created a java maven project using pom.xml
jenkins job has been created to run the ReadyAPI suite directly but want to run using the java project which include pom.xml
Run the ReadyAPI project using maven with help of jenkins.
Need to provide some videos in which i can solve the issue which i am currently facing.
I think you need to split this question into two concerns:
How do you call Maven from Jenkins?
And once you've got that, you need to think about...
How do I run a SoapUI/ReadyAPI project from Maven?
The first question is addressed here:
https://www.youtube.com/watch?v=pts8zdHel5E
The second question is addressed here:
https://support.smartbear.com/readyapi/docs/integrations/maven/example.html
If you have already covered the basics here, and got some specific problem, you need to provide more information to your specific situation.

Use of maven with artifactory and jenkins

I am very new to maven, artifactory and jenkins as well. I made a directory 'repository' under path /home/apache-maven-3.2.1/.m2/repository. I am trying to deploy a jar through artifactory UI into this directory. Please suggest some configuration so that i can do this. Jars which i deployed already were deployed successfully but when I see inside repository, there is nothing in it.
One other question is how to set dependencies while deploying any artifacts?
These questions may be silly because i don't know anything about the above three tools and i am unable to set relation between them also.
Thanks in advance.
I'm also quite new to maven and still struggling with it, but the thing to do is try to configure a pom.xml file with your settings. Since you didn't give any indication on how the jar file has to be build, you got to find a guide in order to do it.
Useful links:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
https://www.tutorialspoint.com/maven/maven_pom.htm
Hope this can help!

How to skip a maven build step without modifying the pom itself?

We have a maven based Java EE project controlled by the customer. For internal reasons, we cannot execute one of the build steps, but the rest works fine and produces the jar we want.
Since editing the pom file would require taking care when committing to customer's SVN and copying the pom file would require taking care to sync changes comming from there, we are looking for a way to skip this specific step in the build section during the maven call itself, so to say mvn clean install but-leave-out-this-build-plugin-step, is there any?
Edit:
The plugin in question is the rpm-maven-plugin, which prevents the build from running on Windows. We found information how to make it work which won't really fit in our current setup. And since we cannot modify the customer's pom, I was looking for a way to trigger the skipping externally. But maybe there are other ways to just ignore/skip/fake this step?
It depends on what plugin you want to skip. Many plugins have ability to be skipped via system property (-Dblabla).
For deploy plugin it is -Dmaven.deploy.skip=true, for surefire -DskipTests=true.
Read plugin documentation, maybe you can find skip property
The rpm plugin hase a property disabled, unfortunately it is not accessible by a property. So, if setting this property in the customer's pom (or asking for editing it) with a default value of false is an option, this may be the solution.

JSLinter for Maven 2

I am looking for an automated way to validate my JS code during Maven build process.
One of the projects I found is JSlint4Java. What I discovered the hard way, it works only with Maven 3, unfortunately.
You could try Wro4j with JSHint. It works great in my projects.
https://code.google.com/p/wro4j/
well I dont any way about maven. but Hudson build tool also have integration with JSLint. Maybe you can integrate with your build server

How to easily copy/rename/remove files with Maven (as in Ant)

I am working on a project and using Maven to build it. The project is a quite big Java web application and it is supposed to work with both Mysql and Oracle databases.
The problem is that there are some specific annotations related to either of the two databases in the source code, plus some other differences, so that I am forced to manually comment/uncomment part of the code before building the application for one of the two databases.
Basically what I would like to achieve is to have my build script, maybe via a Maven profile, to automatically switch the source classes before building depending on the database I want my war to work against.
Putting it simply, the idea is to have MyClass.oracle and MyClass.mysql, and depending on my build profile I should move one of the two in the source dir, rename it MyClass and build. This should be done for some packages, classes, and also configuration files.
Is there any way I can achieve it via "pure" Maven? The only solution I came across till now is to use an antrun plugin and reference an Ant build.xml inside of it.
Thank you,
Mattia
A pure maven solution would be to develop your own maven plugin. Depending on your requirements this can be an overkill, however it is not hard at all, you can see how to achieve this here.
This is a limitation of Maven. One of Maven's purposes is to not have a build script. You should simply use the plugins as available, and setup your project the right way, and magically, everything will build!
There is one solution: Use Ant. Well, not to redo your whole project with Ant, but with the antrun plugin, you can run a few Ant tasks at various phases of your Maven build life cycle.
It's been a long, long time since I've used this, so I am not going to try to write a test pom.xml, but I don't remember it being very difficult to use.
Of course, the correct Maven solution is to divide your project up into "common core" code, and then a separate Oracle and MySql client that uses the "common core". By the way, I hope you're not patching source code. Instead, you're using a properties file to do this for you.

Resources