Showing posts with label maven. Show all posts
Showing posts with label maven. Show all posts

Tuesday, January 3, 2017

Process maven's pom xml file with xmlstarlet

General command  to get version of certain plugin dependency from pom file:

xmlstarlet sel -N pom=http://maven.apache.org/POM/4.0.0 -t -m "/pom:project/pom:build/pom:pluginManagement/pom:plugins/pom:plugin[pom:artifactId='maven-checkstyle-plugin']/pom:dependencies/pom:dependency[pom:artifactId='checkstyle']/pom:version" -v . pom.xml

Examples for editing and selection are at:
https://github.com/sevntu-checkstyle/sevntu.checkstyle/blob/master/pom-version-bump.sh

https://github.com/checkstyle/checkstyle/wiki/How-to-generate-Checkstyle-report-for-Google-Guava-project

Few XPATH conditions for query:
http://stackoverflow.com/questions/28370054/find-a-specific-groupid-from-a-maven-pom-xml-using-xmstarlet


Useful command to print all tags from xml file to help construct XPATH:
xmlstarlet el -v pom.xml


Friday, October 16, 2015

How to cache maven local repo between Travis builds

caching is allowed only for private repos or public repos that use "Using container-based infrastructure".

Steps:
1. instruct travis to use "container-based infrastructure"
2. instruct travis what folder you need to cache

Official documentation:
http://docs.travis-ci.com/user/workers/container-based-infrastructure/#Routing-your-build-to-container-based-infrastructure
http://docs.travis-ci.com/user/caching/#Arbitrary-directories


Results: that caching speedup build on ~3-4 minutes for each jdk.

Example: https://github.com/checkstyle/checkstyle/blob/master/.travis.yml

Saturday, June 14, 2014

"Skipping JaCoCo execution ...." problem in maven project


For Checkstyle project I decided to use coveralls.io service to show UTs coverage as banner.
I used that instruction to make it for java maven project. Amazing documentation with example description worked fire for simple projects(sevntu.checkstyle , dsm-maven-plugin).

But For Checkstyle I had an error:

[romani]$ mvn jacoco:report coveralls:jacoco

...

[INFO] Skipping JaCoCo execution due to missing execution data file:/home/travis/build/checkstyle/checkstyle/target/jacoco.exec

...

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:2.2.0:jacoco (default-cli) on project checkstyle: I/O operation failed: /home/travis/build/checkstyle/checkstyle/target/site/jacoco/jacoco.xml (No such file or directory) -> [Help 1]


That problem is happening when jacoco failed or did not registered his agent to instrument some code and gather statistics before tests are launched. 

Problem was in surefire-plugin, that was declared as:
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <argLine>-Duser.language=en -Duser.country=US</argLine>
        </configuration>
      </plugin>

Proper configuration is (attention to bold part):
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.9</version>
        <configuration>
          <argLine>${argLine} -Duser.language=en -Duser.country=US</argLine>
        </configuration>
      </plugin>
.

final version of my pom.xml (see "travis" profile) and travis.yml.

Useful links that I used for investigation:

Wednesday, January 23, 2013

Maven3 does not update repository to latest plugins

Maven update for plugins (--update-plugins) does not work in maven3. No way to get latest file
https://bg.reveredata.com/maven2/com/revere/maven/plugins/rdbds-maven-plugin/maven-metadata.xml
only one solution - exact version to specify, but in this case maven-metadata.xml is not updated even new plugin is downloaded and used on launch.

Details:
https://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html#Maven3.xCompatibilityNotes-UniqueSnapshotVersionsandClassifiers
- "Automatic Plugin Version Resolution"
- "Plugin Metaversion Resolution"

Launch maven plugin by exact version


source:


mvn groupID:artifactID:version:goal
Example:
mvn org.apache.maven.plugins:maven-checkstyle-plugin:2.5:checkstyle



Saturday, September 8, 2012

Eclipse complains about com.sun.tools 1.5.0 is missing

During compilation of some opensource project you could come up to error "artifact  com.sun.tools 1.5.0 is missing" in Eclipse, but compilation works fine from terminal.

Problem is in what JDK Eclipse use and provide it the same path.
check correctness of $JAVA_HOME
You need to check $PATH variable to be sure that required JDK is in Path.
Even you have JAVA_HOME/bin in path, java could be taken from other location due to the fact that it could be found in path early than your, to check it:
which java
ls -la /usr/bin/java
ls -la /etc/alternatives/java
Make sure that /etc/alternatives/java points to your JDK. In my case it was to OpenJDK but my JAVA_HOME was pointed JDK 1.6. So I removed all openjdk packages from Synaptic in Ubuntu and  after that all worked fine.

Similar problem is described here.