maven clean install with release plugin - build

How do we integrate release plugin with clean install. Currently we execute clean install -Pprofile,autoInstallPackage to build and deploy the package to the environment after changing the SNAPSHOT version to release version in pom.xml.
We wanted to enhance the release process which includes updating pom with release version -> deploy using install profile -> creating a new Development Version.
for which clean install release:prepare -Dresume=false -DreleaseVersion=3.2 -Dtag=3.2 -DdevelopmentVersion=3.3 works as well without deployment to environment.
I have problem in executing
`clean install -Pprofile,autoInstallPackage release:prepare -Dresume=false -DreleaseVersion=3.2 -Dtag=3.2 -DdevelopmentVersion=3.3`
this deploys a SNAPSHOT version rather than release version which makes sense as I don't have a proper sequence.
However, Using the below command doesn't work either:
clean \
release:prepare -Dresume=false -DreleaseVersion=3.2 -Dtag=3.2 \
install -Pprofile,autoInstallPackage \
release:prepare -DdevelopmentVersion=3.3
this is trying to execute git tag twice and fails. Still deploys the 3.2-SNAPSHOT version.

Did you try preparationGoals in the Maven-Release-Plugin section of your pom.xml?
To run additional goals after release preparation but before committing, specify them using the preparationGoals property.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<preparationGoals>clean install</preparationGoals>
</configuration>
</plugin>
These maven goals are executed after the release is prepared, but prior to the submission of the release into source control.
The maven release goals are executed in this order:
release:prepare
preparationGoals
release:perform
completionGoals
Also, take a look at this post and see if it also relates to your question.

Related

How to make a NodeJS package build C++/WebAssembly upon install?

How do you structure a NodeJS package, containing wrapped C++ code that's compiled into web assembly, so that when you run npm install <package name>, the compilation step happens?
I have a package mypackage configured so that when I run npm run build in its project directory, C++ code is compiled into web assembly, and this is then bundled with other Javascript for the package.
I'm now trying to use this package from another project, and if I run npm install --save mypackage, it installs the package's Javascript, but doesn't run it's build process, so none of the web assembly is created, resulting in a broken package.
How you do it
In the scriptis section in package.json file, you can add a postinstall script, while will be run each time after a package is installed. You can find more about npm scripts here https://docs.npmjs.com/misc/scripts
inside pacakge.json
...
"scripts": {
...
"postinstall": "npm run build"
}
Should you do it
The only valid reason to make build process happen at the target (consumer) system is if the build is dependent on the operating system or architecture of the target system, or is dependent on some configuration/properties of the target system. If the build is not related then it should be made at publishing time, this way it will be done once for all consumers, saving bandwidth, and time. usually also you save space because the bundled package is less than the source.
If you decide to package the built artifact (your bundled package) then its a good idea to use the prepublish script
"scripts": {
...
// this will make sure that you are always publishing the most updated built artifact, instead of having to manually run build each time you want to publish
"prepublish": "npm run build"
}
Another good idea, is to also exclude the source files from the published package using .npmignore, to actually save space.

Managing npm package installation for non-web developers

I work on a project where I am the only front-end developer amongst a team of C++ developers. When we build our release variant, I want the C++ developers to run the web build process (npm install, grunt/gulp build which does concat/minification/etc...). In order for that to happen, they have to npm install all the devDependencies.
Is there a way to allow them to quickly install the necessary npm modules without having to re-download them ever time npm install is called? Or make the npm install only go through installation once?
npm link doesn't work since that links to the web application and not the node modules that the web application depends upon.
tar.gz would be possible but that means updating the tar.gz every time a node module gets updated.
Curious what development process others suggest for tacking working in a mixed language environment.
You can checkout node_modules to your git or whatever version control you're using, so they won't be downloaded every time.
Yes, someone will have to update modules once in a while, but some people (including npm itself) do just that.
You can also put a caching proxy server (i.e. sinopia) to download packages from, so downloading would be a bit faster.

How to set agentlib property for mvn tomcat plugin (jpda)

Related to
eclipse debug remote web application => How do I debug a remote application in my eclipse
How can I set / archive this in the mvn tomcat plugin?
http://tomcat.apache.org/maven-plugin-2.0-SNAPSHOT/tomcat7-maven-plugin/
The only thing that might help is setting systemProperty but that doesn't work for me ;/
Goal: let tomcat run on console via maven but enable remote debugging for different IDEs
(YES guys, we can run tomcat in Eclipse WTP! That's not the question ;)
$ export MAVEN_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
$ mvn tomcat7:run-war
^^ that's it, not cool (as it is not in POM) but it works
Source: http://aaronz-sakai.blogspot.de/2009/02/debugging-jetty-when-running-mvn.html
It's a bit old thread but for the sake of completeness I though i might add a little here.
The plugin does not provide debug options configuration for whatever strange reason.
Thus your only option is to manually specify debug configuration to the JVM that runs the process.
In your environment, there are three ways achieve this:
Using a well known-maven environment variable (as described by childno.de)
Directly specifying the options to maven (no env. variable needed):
mvn -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y tomcat7:run-war
With an eclipse Run configuration That's basically the same like 2) but you define this in eclipse (that would be good if you didn't want to leave the IDE at all).
To achieve that you need to specify a Maven Build Run configuration.
Set the goal to tomcat7:run (or similar) and then navigate to the JRE tab. The VM arguments area is where you specify the debug configuration: -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
If you opt for 3), the precise run goal for tomcat7 is irrelevant to the debug enabling. Choose according to you use case (dynamic web project, war, etc.). Same goes for the plugin configuration. However, make sure to specify that you are using the tomcat maven plugin in the pluginManagement section of your project pom:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</pluginManagement>
OR... you could simply add the following tag to your plugin configuration
<jpda>true</jpda>
Then when you execute: mvn tomcat7:run, it will start jpda on port 8000.
Funny thing is even though I have tested this and it works, I can't find any code in the opensource code base to explain why it works, nor have I found any way to change from the default port 8000.
Apache seems to have dropped the ball when it comes to documentation of this plugin.

Jetty server best IDE

I want to use Jetty 8.0 Server for my application. Which IDE i will use for simple configuration.
Presently i am using Eclipse. How to configure jetty in Eclipse. Any best example?
I use run-jetty-run, and jetty with maven in eclipse.
http://code.google.com/p/run-jetty-run/
More on jetty maven plugins:
http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
I use run-jetty-run with DCEVM for hotdeploy.
Here's my tutorial, Spring-mvc + Velocity + DCEVM
Most people I know simply write a small embedded usage of jetty for their application. It is dead simple to do and there are a number of examples in the example-jetty-embedded project in jetty git repository. It is also how most of our test cases are written, using jetty itself to test.
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/example-jetty-embedded
If your using maven then the jetty-maven-plugin is a pretty simple way of testing and works with the eclipse plugin Webby which streamlines much of the pain and suffered that is called WTP.
https://docs.sonatype.org/display/M2ECLIPSE/Integration+with+Maven+WAR+Plugin
There is also a Jetty WTP plugin that many people use successfully.
http://wiki.eclipse.org/Jetty_WTP_Plugin
I also use run-jetty-run for Eclipse.
I tried the Jetty plugin for NetBeans, but it didn't work.
I think Jetty for Eclipse is better than Tomcat, cause its simpler to use and configure and a fast server.
Assuming you have setup M2Eclipse plugin within Eclipse correctly and your project is configured to use Maven, I've found Jetty Maven Plugin within Eclipse to be particularly useful. The beauty of this approach is that you can do your development really fast, especially if you have 3rd party dependencies. All you have to do is add the following plugin to your pom.xml:
<project>
...
<build>
<plugins>
...
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
<configuration>
<contextPath>/</contextPath>
</configuration>
</plugin>
...
</plugins>
</build>
...
</project>
To use this plugin successfully here some additional notes on installation and usage:
Eclipse Integration
Install the following Eclipse Plugins first
Maven Integration for Eclipse (Help > Eclipse Marketplace...)
A patch that makes it possible to debug source code at runtime. Eclipse Plugin Link
Next, create a "Maven Build" Eclipse Launcher
You also need to configure "Maven Build" launcher so that you can run the Jetty Server quickly. Follow the instructions below create this launcher:
Right-click on your current project and select (Run As/Debug As) > Maven Build...
Set Goals As rhubarb:start
Check Resolve Workspace artifacts
Save
Going forward, you can simply do: (Run As/Debug As) > Maven Build, and the goal will execute.

Build Maven Project Without Running Unit Tests

How do you build a Maven project without running unit tests?
Currently restructuring some code I have for a Servlet and would like to try it out in my web browser (which means running mvn install to get the .war to upload to Tomcat). I'm fully aware my UNIT tests are failing and I'm fine with that because I will fix it once I have the code the way I want. Can anyone advise?
If you want to skip running and compiling tests:
mvn -Dmaven.test.skip=true install
If you want to compile but not run tests:
mvn install -DskipTests
If you are using eclipse there is a "Skip Tests" checkbox on the configuration page.
Run configurations →
Maven Build →
New →
Main tab →
Skip Tests
Run following command:
mvn clean install -DskipTests=true
With Intellij Toggle Skip Test Mode can be used from Maven Projects tab:
mvn clean install -Dskiptests=true
Now, the only difference from the answers above is that the "T" is in lower case.
I like short version: mvn clean install -DskipTests
It's work too: mvn clean install -DskipTests=true
If you absolutely must, you can also use the maven.test.skip property to skip compiling the tests. maven.test.skip is honored by Surefire, Failsafe and the Compiler Plugin.
mvn clean install -Dmaven.test.skip=true
and you can add config in maven.xml
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
[...]
</project>
If you call your classes tests Maven seems to run them automatically, at least they did for me. Rename the classes and Maven will just go through to verification without running them.