How to make release version of maven-metadata.xml to be HIGHEST version number? - maven-2

I have a project A which needs AAA:BBB as a dependency.
<dependency>
<groupId>AAA</groupId>
<artifactId>BBB</artifactId>
<version>RELEASE</version>
</dependency>
After deploying a branch version(say, 0.2.1-4) of AAA:BBB, release version number is the latest deployed version number (0.2.1-4), not the HIGHEST number(0.3.3).
maven-metadata.xml:
<metadata>
<groupId>AAA</groupId>
<artifactId>BBB</artifactId>
<versioning>
<latest>0.3.3</latest>
<release>**0.2.1-4**</release>
<versions>
<version>0.1.0</version>
<version>0.1.0-1</version>
<version>0.1.0-2</version>
<version>0.2.1</version>
<version>0.2.1-3</version>
<version>0.3.1</version>
<version>0.3.3</version>
<version>**0.2.1-4**</version>
</versions>
<lastUpdated>20130628092226</lastUpdated>
</versioning>
</metadata>
Therefore when building project A, the RELEASE version number of AAA:BBB will be resolved to 0.2.1-4, not 0.3.3, which causes the build failed.
Only after ***rebuiling metadata via Sonatype nuxus UI*** can we have the HIGHEST version number.
maven-metadata.xml with sorted version number after rebuilding metadata:
<metadata>
<groupId>AAA</groupId>
<artifactId>BBB</artifactId>
<versioning>
<latest>0.3.3</latest>
<release>**0.3.3**</release>
<versions>
<version>0.1.0</version>
<version>0.1.0-1</version>
<version>0.1.0-2</version>
<version>0.2.1</version>
<version>0.2.1-3</version>
<version>0.2.1-4</version>
<version>0.3.1</version>
<version>**0.3.3**</version>
</versions>
<lastUpdated>20130628092226</lastUpdated>
</versioning>
</metadata>
Is it possible to update maven-metadata.xml's RELEASE VERSION to HIGHEST VERSION number after deploying an artifact?
Thanks.

Related

Can I use a new version of a library that is loaded by the Mule system classloader?

I have a dependency that requires a new version of com.fasterxml.jackson.databind.
Here is the maven config for that dependency:
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.5</version>
</dependency
Mule 3.7.0 uses version 2.4.3.
I've tried setting an override in the mule-deploy.properties file:
loader.override=com.fasterxml.jackson.databind
I've also tried using apache shade to re-locate/re-name the conflicting package with the following config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<artifactSet>
<includes>
<include>com.fasterxml.jackson.core:jackson-databind</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.fasterxml.jackson.core</pattern>
<shadedPattern>shaded.fasterxml.jackson.core.databind</shadedPattern>
</relocation>
</relocations>
</configuration>
Is there something about either of the two above approaches that is wrong, or is there another way to include a conflicting version of a dependency in the pom that is also loaded in as a different version by the Mule System classloader?

Latest maven dependency version for pentao kettle

I want to mavenize pentaho kettle plugin development, and using below xml code in pom.xml to upgrade the current version 4.4.0 stable to the latest one.
I Used 6.0.0.1-364 , but 6.1 is stable latest according to pentaho site. Then what is the corresponding maven dependency for the same?
Here http://repo.pentaho.org/content/grou...e/kettle-core/ I can see the list of kettle maven dependencies . But which one is latest and stable version ? Please help me understand
<dependencies>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>6.0.0.1-364</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>6.0.0.1-364</version>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-ui-swt</artifactId>
<version>6.0.0.1-364</version>
</dependency>
</dependencies>
AFAK you should use the maven dependency corresponding to the PDI version installed in your system. So if you are using Kettle version of 6.0.0.1-364 then use the same maven dependency. Now from the above link, it seems that the latest version is 6.1.0.2-208. If you are looking for the latest version, it is 6.1.0.2
POM link: http://repo.pentaho.org/content/groups/omni/pentaho-kettle/kettle-core/6.1.0.2-208/kettle-core-6.1.0.2-208.pom
Hope it helps :)

building maven flex project with flex mojo depending on apache sdk fail

I have a mavenized flex project wich builds fine with adobe sdke 4.6.
Now , i'm trying to compile it with apache recent sdk .
I mavenized the sdk and copied the dependencies in local repo .
the apache version that i mavenized is : 4.13.0.20140701 .
my pom is as below :
<properties>
<flexmojos.version>7.0.1</flexmojos.version>
<flex.version>4.13.0.20140701</flex.version>
<flash.version>11.1</flash.version>
</properties>
<build>
<sourceDirectory>src/main/flex</sourceDirectory>
<plugins>
<plugin>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-maven-plugin</artifactId>
<version>${flexmojos.version}</version>
<extensions>true</extensions>
<configuration>
<debug>true</debug>
<sourceFile>ComptaFlex.mxml</sourceFile>
<services>${basedir}/src/main/flex/services/services-config.xml</services>
<compilerWarnings>
<warn-no-constructor>false</warn-no-constructor>
</compilerWarnings>
</configuration>
<dependencies>
<!-- This handles a bug in maven which causes problems with flex resources -->
<dependency>
<groupId>net.flexmojos.oss</groupId>
<artifactId>flexmojos-threadlocaltoolkit-wrapper</artifactId>
<version>${flexmojos.version}</version>
</dependency>
<!-- Without this FM will use the compiler configured in its master
pom, which will result in version conflicts -->
<dependency>
<groupId>org.apache.flex</groupId>
<artifactId>compiler</artifactId>
<version>4.13.0.20140701</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
<plugin>
I got maven compile error as :
xmojos.oss:flexmojos-flex-compiler:jar:7.0.1 -> net.flexmojos.oss:flexmojos-generator-internal-compiler-iface:jar:7.0.1 -> org.apache.flex:compiler:pom:4.12.1.20140427: Failed to read artifact descriptor for org.apache.flex:compiler:pom:4.12.1.20140427: Could not transfer artifact org.apache.
it seems that flex mojo always use a default apache version and ignores mine provided . how could i force flexmojo build with my given version .
Flexmojos-maven-plugin version 7.0.x is built using FDK 4.12.1.20140427. This FDK declared as dependency to this maven plugin.
You need firstly mavenize FDK 4.12.1.20140427 and put it to you maven repository. Only after that you can mavenize other versions of FDK.
A dirty work around is to change flexmojo-parent pom file : and edit by hand :
<flex.version>4.13.0.20140701</flex.version>
until flexmojo developpers comes with a better response .
I have written quite a bit of documentation lately, please check-out at: https://cwiki.apache.org/confluence/display/FLEX/Preparing+FDKs+for+Maven+builds
The short version:
We have created a maven extension that should automatically download and install Flex SDKs as they are referenced in the maven build. Also Flexmojos 7.1.0-SNAPSHOT has been updated to no longer contain a reference to any FDK artifact. Also we now use 3-segment versions such as: 4.14.1

Alternative IndexProvider for Neo4J 1.9.1

I'm using Lucene 4 in my application and don't want to change this. I'm trying to integrate Neo4J which bundles Lucene 3.5 as an IndexProvider implementation, neo4j-lucene-index.
Unfortunately, neo4j-lucene-index does not work, and with that dependency excluded, the app just hangs indefinitely on start up. I've tried neo4j-lucene4-index but that does not seem to be maintained very well and needs to be updated quite significantly to work with Neo4J 1.9.1. The changes go way beyond my understanding of the internals of Neo4J.
However, I can see that IndexProviders are pluggable, so I'm hoping that there is an existing alternative to Lucene - I can't find it at the moment though. Can anyone point me in the right direction for one?
It seems strange that Lucene 4 has been out for so long now and Neo4J doesn't support it. Am I missing something?
Currently, my POM looks like this for my Neo4J config:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>2.2.1.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>neo4j</artifactId>
<groupId>org.neo4j</groupId>
</exclusion>
<exclusion>
<artifactId>neo4j-cypher</artifactId>
<groupId>org.neo4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>1.9.1</version>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
</exclusion>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>1.9.1</version>
<exclusions>
<exclusion>
<artifactId>neo4j</artifactId>
<groupId>org.neo4j</groupId>
</exclusion>
<exclusion>
<artifactId>neo4j-cypher</artifactId>
<groupId>org.neo4j</groupId>
</exclusion>
<exclusion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- A temporary dependency until Neo4J builds in support for Lucene 4.
Looks like they're planning to incorporate this project anyway This project
is available on GitHub, and needs to be built with: mvn license:format mvn
install to install into your local repo.
<dependency>
<groupId>com.keatext</groupId>
<artifactId>neo4j-lucene4-index</artifactId>
<version>1.9.M01-SNAPSHOT</version>
</dependency>-->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.1.Final</version>
</dependency>
There have been some changes internally from 1.8 -> 1.9. In short, a index provider must register a KernelExtensionFactory via META-INF/services, see https://github.com/neo4j/neo4j/blob/master/community/lucene-index/src/main/resources/META-INF/services/org.neo4j.kernel.extension.KernelExtensionFactory
This KernelExtensionFactory is the entry point, just checkout the Lucene 3 based implementation at https://github.com/neo4j/neo4j/tree/master/community/lucene-index.
Some time ago, I was also faced with this issue: I was working on prototyping, and I really liked embedded mode of Neo4j. But, once I decided to use Lucene 4 - I was stumbled with incompatibility issue.
OSGi
As been suggested here: How to use two versions of jar in my java project - one of the possible solution is to use OSGi, and wrap Neo4j and Lucene 4 into different bundles. Each bundle will have separate classloader - so Neo4j will use in runtime classes from Lucene 3, but you still be able to use Lucene 4 for your purposes.
But, as far as I was working on prototyping - I didn't want to spend time on adaptation of my project for OSGi platform by the single reason of incompatibility of two components.
Maven Shade Plugin
So, I have solved issue with help of Maven Shade Plugin.
Maven Shade Plugin provides an ability to merge all dependencies into single "fat" JAR (also, called "uber JAR").
So, you can generate "uber Neo4j dependency", and use it in your project - instead of "real" Neo4j dependency.
But there is an additional important moment: Lucene 3 and Lucene 4 has the same package structure, and many classes still have the same names. So, this might cause classloading conflicts.
To address this issue, Maven Shade Plugin provides an ability to relocate classes during generation of of "uber JAR": http://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
You can specify package name, and during packaging - Shade Plugin will move classes from specified package and its subpackages to some other package, and will rewrite affected bytecode.
So, during composing of "uber JAR" for Neo4j - you can configure Shade Plugin to move classes of Lucene 3 to some other package, e.g.:
org.apache.lucene.* -> shaded_3_6_2.org.apache.lucene.*
(Luckily, it seems that Neo4j doesn't use reflection, in application to Lucene stuff).
So, you can create empty maven project with following pom.xml:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.hack</groupId>
<artifactId>uber-neo4j</artifactId>
<version>1.9.3</version>
<packaging>jar</packaging>
<name>uber-neo4j</name>
<properties>
<neo4j-version>1.9.3</neo4j-version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>${neo4j-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<relocations>
<relocation>
<pattern>org.apache.lucene</pattern>
<shadedPattern>shaded_lucene_3_6_2.org.apache.lucene</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>neo4j-repo</id>
<name>Neo4j Repository</name>
<url>http://m2.neo4j.org/content/repositories/releases</url>
</repository>
</repositories>
</project>
Described configuration - provides an ability to generate "uber JAR" for Neo4j with renamed packages of Lucene 3 (just do mvn install).
And, finally, you can attach this stuff as a module to your maven project.
So, after this workaround - you will be able to use both: Neo4j and Lucene 4 in your project.
Just in case, here is link to GitHub repository with maven configuration for generation of "uber JAR" for Neo4j: https://github.com/lagodiuk/neo4j-uber-jar
If you don't care what index Neo4j uses, and you're using Maven to manage dependencies, you can use the Maven Shade plugin's class relocation feature to rename Neo4j's Lucene dependency so it doesn't conflict with other dependencies on newer versions of Lucene.
In my case this required moving Neo4j-dependent code into a separate Maven project, as Shade acts on a whole project/jar at once. So if you can get your conflicting Lucene dependencies into different projects, this should work great.

Make Ivy recognize ant#ant and ant#org.apache.ant are conflicts

My build has both ant-1.7.0.jar and ant-1.6.2.jar in it, and this is breaking tests. Looking at the ivy:report, it appears that 1.6.2 is resolved as ant#ant, and 1.7 is ant#org.apache.ant.
So how can I configure Ivy to treat ant and org.apache.ant as the same organization?
You can't but you can create a global exclusion:
<ivy-module version="2.0">
..
..
<dependencies>
..
..
<!-- Global exclusions -->
<exclude org="ant" module="ant"/>
</dependencies>
</ivy-module>