Scoping out maven plugin execution depending on environments - maven

I am using the ready-api-maven plugin for executing simple SOAP requests on my codebase which is deployed to a local JBoss server before the execution of the tests.
I am trying to figure out how to "scope out" the steps to deploy to a local JBoss server and run these tests when the build is executing on Jenkins. These tests are meant only for executing on a local system.
I'm quite new to maven and would really appreciate the help. Thank you

You can define it by using profiles. ex. you can specify two profiles: local and ci, in local profile you can specify to run the tests but in ci you can skip them.

Related

Running integration tests remotely with maven

How can I run integration tests on an environment other than the one I'm building (running maven) from? I suppose I should use the failsafe plugin, but how would it find the artifact remotely, run the tests and return results?
Specifically: I want to run my tests on a controlled environment, a docker container, regardless of building from the build server or a dev machine.

What is the purpose of tomcat-maven-plugin?

I'm having some difficulty understanding the purpose of this plugin. Is it to modify the settings in Tomcat during the build?
I am deploying to tomcat using maven, without the plugin and it seems to work fine. Not sure if I am missing something
Cheers
Maven Tomcat plugin basically just bootstraps an embedded Tomcat container for you. Saves you the trouble of configuring an external Tomcat instance for development purposes. It can also auto-start this Tomcat instance during the build and run integration tests on it, stopping it afterwards.
If you already have a functioning workflow that you're comfortable with, no need to introduce the plugin, but it's pretty easy to configure, can run multiple web apps, can run unassembled applications etc so it's convenient to have for local development.
An even more light-weight alternative would be the Jetty plugin which starts an embedded Jetty server instead.
Maven is actually a plugin execution framework where every task is actually done by plugins.
Maven Plugins are generally used to :
create jar file
create war file
compile code files
unit testing of code
create project documentation
create project reports
A plugin generally provides a set of goals and which can be executed using following syntax:
mvn [plugin-name]:[goal-name]
For example, a Java project can be compiled with the maven-compiler-plugin's compile-goal by running following command
mvn compiler:compile
for more information go to http://www.tutorialspoint.com/maven/maven_plugins.htm
so pulgins is used to execute goals.
suppose if you don't include plugin that is required in your execution environment then it will throw an error like
A required class is missing: Lorg/apache/maven/plugin/BuildPluginManager;
so by adding appropriate plugin in pom.xml it will resolve the dependencies and execute the goal succesfully.
to remove above error just add the following plugins :
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-amps-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
</plugin>
Maven is a framework used to build JAVA applications, it provides the following
Directory Structure
Configuration Files
Build Settings
It helps in easy and structured development, primarily used for REST API Calls.
Applications built on Maven Framework, would require the same to be deployed
Its better that you get the plugin installed, since on a long run you never know what dependency may go missing
-If this helps, Mark as Answer

How Do I Properly Deploy With An Integration Test Project?

My projects are structured as:
root
common
client
server
test
server and client depend on common. test is a project that contains integration tests and these tests depend on client common and server.
If I add all of these as modules to root, then when I execute mvn deploy on root it will deploy the jars, and then run the integration tests. I only want to hit the deploy phase if my integration tests run successfully.
Is this possible with Maven?
You shouldn't run mvn deploy directly but use the release plugin instead. You have to run
mvn release:prepare release:perform
for doing and deplying a relase. See also this blog post about deploying snapshots.

Maven deploy multi module project only if all modules build successfully

I have a maven multi module project with several modules. I want to deploy them (mvn deploy) only if they all pass a full mvn install (which includes the tests).
Currently, I run a mvn install on the project. If all modules pass, I run mvn deploy to do the deployment. The problem I see is the waste of time calling mvn twice (even if I skip tests on the second run).
Does anyone have an idea on this?
EDIT: I have learned that using Artifactory as a repository manager and the maven-artifactory-plugin with your maven setup will add the atomic deploy behaviour to the mvn deploy command. See the Build Integration section in the Artifactory documentation.
[DISCLOSURE - I'm associated with JFrog. Artifactory creator.]
Take a look at the deployAtEnd parameter of Maven Deployment plugin: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
This is a bit tricky. Maven is not atomic when it executes the build life-cycle. So a broken set of artifacts may end up in a repository.
One solution I know is Nexus Pro: http://www.sonatype.com/Products/Nexus-Professional/Features - it allows you to promote builds or define certain repos as staging. So only verified versions get promoted to be used. Maybe artifactory has something similar - I just don't know.
If that solution is too expensive you probably need to create a cleanup build or profile to remove artifacts that where already uploaded. My first guess would be to write a Maven plugin to use the the proxy remote API or maybe the maven features are already sufficient. But since deploy means update the meta-data xml files too I dont think there is a delete - not sure on this either.

Automatic features provision on Fuse ESB/Servicemix with Maven

Is there any way to provision/deploy features to Fuse ESB/Servicemix automaticaly though Maven, like cargo for Tomcat? Using ant+ssh is not an option.
I'm currently finalizing a client wrapped in a maven plugin that will do just that, but instead of the fusesource approach of using the hot deployment folder I connect directly to the remote karaf console and execute the commands required to (un)install features.
The auto deploy is part of automated regression tests executed by Jenkins through a set of SoapUI test scripts.
Basically I use apache SSHD to connect to karaf (see an example here: https://cwiki.apache.org/KARAF/63-programmatically-connect-to-the-console.html) and some custom code to execute the commands and parse the result.

Resources