apache_maven

These things have disturbed us (The developer Team at Innoveo.com) a lot in the past months. We did solve them recently, and I would like to publish them now here to help more people

Someone create a new maven module, after updating from SVN the module is not visible as a separate project.

Scenario:

  1. User A checks out a maven project from SVN using "Checkout as Maven Project". All modules are now listed as separate projects in Eclipse
  2. User B creates a new module in the project, and checks it into SVN
  3. User A updates project
  4. New module does not show up as a separate project.

Solution:

  1. Work around found by selecting the parent project
  2. Do Import -> Maven.
  3. Select then the same name template and most modules should be grayed out because of name conflicts. But you should see the missing module in the list
  4. Tick the one (new) module and import it.

In SVN perspective, when I choose "Checkout as Maven Project" on maven projectA, I get an exception saying that maven.123457896 can not be renamed

Scenario:

This error occur sometime, especially if you ever kill eclipse during a previous maven checkout (as sometimes it seems to hang forever). In fact the error message can be misleading,as M2Eclipse can not renamed maven.1234567896 to projectA as it may partially exist on disk.

Solution:

  1. Stop eclipse
  2. Go to the workspace location {workpsace_loc} 
  3. Delete the directory maven.1234567896 or any directory starting with maven.xxxxxxxx
  4. Delete also the temporary created Maven project  {workpsace_loc}\projectA directory you were trying to checkout if it exist.
  5. Restart eclipse, and in SVN perspective, on maven project A, retry and  select "Checkout as maven project"

.classpath or .project are not committed in SVN, how to add them?

Scenario:

You may have add a svn:ignore on some directories, or some someone may have committed a recursive svn:ignore properties on some module in the hierarchy. While we should never commit any .classpath to SVN, there is some rare case where it is still needed. For example if you ever add special runtime server libraries that may not be coming from Maven Dependencies.

Solution:

Even if there is a svn:ignore on a maven module, or if a module has applied svn:ignore properties to all its child, you can always put a file under version control by doing the following

  1. Go in SVN perspective
  2. Drill down to the Maven module location or directory in which you would like to add a file
  3. Right click New... then choose File,
  4. A pop up will open letting you choose a file on disk
  5. Don’t forget to Enter a commit comment

 

Maven Surefire runs multiple times our test case when using goal site

This is neither a bug or an issue of Maven, it look like even to be a feature!

Some reporting plugin are modifying (instrumentation) the java byte code of test cases like with Cobertura (goal: cobertura:cobertura).

The Cobertura tool is a free and easy to use source code test coverage analyses. It helps you to discover where your source-code lacks in test coverage.

In some rare case scenario (multi threaded test cases for example), it may be worth to run the code twice as instrumentation may modify behaviors and outcome of tests. So to resume, maven Surefire run them once, then Cobertura one more time but instrumented. One solution among other to escape this is to use Maven profiles, and to rely on another build that do not use reporting to run tests without instrumentation.

More to come ..

comments powered by Disqus

You might like also

Fetching artifact programmatically through REST/API in Nexus 3.x
There is so many case where it is desirable to pull down artifact from Sonatype Nexus using REST API, unfortunately Nexus 3.x Rest API are still under development... Some use cases in Nexus 2.x: You have a script that uses REST call to pull down the LATEST maven artifacts every night from Nexus and deploys them. You make extensive use of the REST API in all your puppet modules You use the Atlassian Puppet module for Nexus for creating repository, …
601 Days ago
git-branch-renamer-maven-plugin
When working with many feature/release/bugix/hotfix branches, it is a bad idea to start changing the pom version as this will create merge conflicts using pull request. this plugin allow you to keep in ALL branches the same pom version for all your projects, for example MASTER-SNAPSHOT the version will be derived from branch name automagically :-) You may want to read more first these 2 short articles Update Maven pom version on GIT checkout in TeamCity maven-release-plugin with GIT git-branch-renamer-maven-plugin …
613 Days ago
Review: Getting Started with Apache Maven by Russell Gold
Some time ago I was asked if I would like to write a review about one of the new video courses from Packt Publishing. It was "Getting Started with Apache Maven" http://bit.ly/1fycmpP by Russell Gold and since I have been using Maven for some years now (since 2007) and did publish some articles myself, I thought it would be nice to help them promote Apache Maven. The course is organized in eight chapters, forty videos with a length between two …
1800 Days ago
Update Maven pom version on GIT checkout in TeamCity
Here is a solution to the following problems Deriving Maven artifact version from GIT branch, Update pom version on GIT checkout automatically, Add the ability to use Pull request with Apache Maven. You have a workflow requirement that require you to have the artifact version of a module externally defined from the current branch in GIT. For example You want to start working on a new feature branch “feature-memory-improvement”, so you branch from master a new branch named feature/feature-memory-improvement Having …
1805 Days ago
Easily Compress Web Application Resources with EhCache
Resources such as JavaScript and CSS files can be compressed before being sent to the browser, improving network efficiencies and application load time in certain case. If you are not using Apache with mod_deflate or nginx in front of your web application, you may need to implement resources compression yourself…. Wait! don’t start writing your own filter to compress files like CSS, html, txt, javascript it is way more difficult than you think to properly handle http response headers and …
2287 Days ago
Tomcat 7 and Apache Maven
Here is 3 different way to control the lifetime a local Tomcat 7 container using Apache Maven. A typical scenario would be to start a servlet container prior to running integration tests (Selenium, SAHI or using any other framework you can think of ) With the following examples, you will be able to start an instance of Tomcat 7 running your web application in the pre-integration-test phase and stop the instance in the post-integration-test phase. You can also decide to …
2287 Days ago
Apache Maven copy local file to a remote server server using SSH
I will show you in an Apache Maven configuration file how to copy files to server each time the package phase is executed. Solution with Ant SCP task This snippet of code is a ready to use code that make use of Apache Ant task scp, Just put this snippet of code in your Maven module where the assembly is executed or anywhere else to push all tar.gz files to a server just run a maven mvn package, you can …
2475 Days ago
Apache M2Eclipse: Get rid of Duplicate resources when opening resources and types
In this small post, I’ll show you how to remove duplicated resources in the Open Resource view of Eclipse Eclipse – M2Eclipse – Subversive …
2481 Days ago
Apache Maven 3 Cookbook
&160; First a big thanks to Packt Publishing for having sent me this book to review! I did enjoy going through this book, while I did not learn a lot of new stuff (I am using Apache Maven daily since 2006!), I found it to be concise and would recommend it anytime to any of my colleagues. But let’s go through my review of this cookbook of over 50 recipes towards optimal Java Software Engineering with Maven 3: Apache Maven
2623 Days ago
Apache Maven 3 Cookbook Review
Thanks to Packt Publishing for having sent me this book to review. I will publish a review in the next coming days Grasp the fundamentals and extend Apache Maven 3 to meet your needs Implement engineering practices in your application development process with Apache Maven Collaboration techniques for Agile teams with Apache Maven Use Apache Maven with Java, Enterprise Frameworks, and various other cutting-edge technologies Develop for Google Web Toolkit, Google App Engine, and Android Platforms using Apache Maven You …
2669 Days ago