When a Ivy project depends a maven project (using assembly plugin), there will be problems. For example:
Maven project:
Suppose the maven project will deploy 2 snapshot packages: for exmaple, one is my-app-1.0.0-20130504.000602-1.jar and the other is my-app-1.0.0-20130504.001348-1-myzip.zip. The pom.xml is shown below.
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>
<... ...>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<packaging>zip</packaging>
<file>my-app-1.01-myzip.zip</file>
</configuration>
</plugin>
</plugins>
</build>
</project>
The Ivy project
The Ivy project depends on the 2 artifacts published by above maven project. The ivy.xml is shown below:
<configurations>
<conf name="get-maven" />
</configurations>
<dependencies>
<dependency org="com.mycompany.app" name="my-app" rev="1.0.0-SNAPSHOT" changing="true" conf="get-maven->default">
<artifact name="my-app" ext="jar" type="jar"></artifact>
<artifact name="my-app" ext="zip" type="zip" m:classifier="myzip"></artifact>
</dependency>
</dependencies>
Issues:
Each time when the maven project deploy new snapshot to the artifactory server, the ivy project can retrieve the latest my-app-xxx.jar from the artifacory server but it can't retrieve the latest my-app-xxx-myzip.zip (ivy can't get to know that the zip is updated and just retrieve the zip from local cache).
What I have to do is to delete the local cache, and run the ivy project again.
I did some investigation, and found the ivy task "convertpom" didn't convert the app-xxx-myzip.zip from pom to ivy, and only 1 artifact (the my-app-xxx.jar) can be found in the converted ivy.xml. Not sure if this is the root cause.
Can anyone help on this? How can I get the lastet snapshots for both artifacts in ivy project?
Regards,
Alben
So to clarify, you're attempting to configure ivy to pull down a snapshot dependency published by a Maven project?
In that case, the following answer will help to explain:
What's wrong with this Ivy changingPattern / SNAPSHOT configuration?
Related
I have a multi-module Maven project where the project version is set via the revision variable.
<groupId>pricing</groupId>
<artifactId>pricing-backend-pom</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<revision>3.0.7</revision>
</properties>
<modules>
<module>pricing-backend-war</module>
<module>pricing-backend-model</module>
<module>pricing-backend-client</module>
</modules>
<build>
<plugins>
<!-- flatten before deploy. removes $revision -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>1.2.7</version>
<configuration>
</configuration>
<executions>
<!-- enable flattening -->
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<!-- ensure proper cleanup -->
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
During the Gitlab build, the project is deployed to a Nexus repository. Each module and the parent appear in Nexus but only the modules appear to be flattened. The module POMs each contain <version>3.0.7</version> but the parent POM still contains <version>${revision}</version>.
I find it difficult to understand why the parent is deployed differently to the modules. I have checked the build logs but cannot see any indication that the parent is handled in a different way.
The parent POM taken from Nexus:
<groupId>pricing</groupId>
<artifactId>pricing-backend-pom</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<revision>3.0.7</revision>
...
A module POM:
<groupId>pricing</groupId>
<artifactId>pricing-backend-client</artifactId>
<version>3.0.7</version>
<dependencies>
...
The build applies the required version:
$ echo New version= ${MAVEN_VERSION}
New version= -Drevision=3.0.7-SNAPSHOT
$ mvn $MAVEN_CLI_OPTS ${MAVEN_VERSION} deploy -DskipTests
The pom file to be installed can be explicitly set:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<configuration>
<pomFile>.flattened-pom.xml</pomFile>
</configuration>
</plugin>
Above, flatten-maven-plugin has been previously invoked to produce .flattened-pom.xml
If you do a test by adding -Drevision=<someVersion> to the command line, does that produce correct results in Nexus?
I suspect it will.
Properties are interpolated very early in the process. When the command first runs, ${revision} is undefined, so Maven leaves it as-is. The flatten then calculates ${revision}, but that only applies from the time the plugin runs and later.
You can try researching "late binding" properties (they start with '#' instead of '$') but I'm not sure if those work in top level fields like the GAV coords.
I'm trying to use the cargo maven plugin just to start a JBoss AS 7 server from maven, without executing any deployments.
I'm able to start the server but as I can read in cargo pluging documentation the goals cargo:run and cargo:start will deploy automatically the current project if project's packaging is Java EE (WAR, EAR, etc.) and if I'm not using deployable sections in the plugin configuration.
This is my simple cargo plugin section in the pom file:
<plugins>
...
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.13</version>
<configuration>
<!-- Container configuration -->
<container>
<containerId>jboss73x</containerId>
<home>${jboss-as.home}</home>
</container>
</configuration>
</plugin>
...
</plugins>
Since I'm not using deployables and the project packaging is war, cargo automatically deploys my project when the server starts.
I would like use the goal cargo:run just to start my local server without deploy any project artifacts.
Is it possible with the cargo maven plugin? Any idea or alternative?
I think that it might not be possible to ask the plugin not to deploy the project in which it is configured, when you are in the case of a deployable archive project.
But what you could do is creating a pom project, with no source in it just the pom.xml, and run your cargo plugin in that project.
My example below starts and stops the cargo plugin when I run the goal install on it :
<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>fr.fabien.perso</groupId>
<artifactId>pom-project-tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<configuration>
<container>
<type>embedded</type>
</container>
</configuration>
</plugin>
</plugins>
</build>
</project>
Yes Yersan, it is possible to start the server without self built artifact deployment. It can be achieved by adding an empty <deployer /> element on the <configuration> tag of the project.
I found the info at the cargo plugin reference site. In addition, I have tested the configuration in my local project to confirm it works.
In my POM.xml other the plugin configuration, i am not required to configure any dependenices to run the plugin. I would like to download dependent jars used by plugin(soapui-maven-plugin) from the repository into one single folder. I tried the command "mvn dependency:copy-dependencies", but no jars are copied. Is there any way to do it?
<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>service.report</groupId>
<artifactId>service-report</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<build>
<plugins>
<plugin>
<groupId>com.smartbear.soapui</groupId>
<artifactId>soapui-maven-plugin</artifactId>
<version>5.0.0</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>loadtest</goal>
</goals>
<configuration>
<projectFile>${basedir}/src/main/resources/xxxxx-soapui-project.xml</projectFile>
<testSuite>xxxx</testSuite>
<testCase>sssss</testCase>
<loadTest>LoadTest 1</loadTest>
<outputFolder>${basedir}/target/surefire</outputFolder>
<junitReport>true</junitReport>
<exportAll>true</exportAll>
<printReport>true</printReport>
<testFailIgnore>false</testFailIgnore>
<!-- <projectProperties>
<value>message=Hello World!</value>
</projectProperties> -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
mvn dependency:copy-dependencies is only applied to current maven module only. It won't works on plugins. If you want to download all soapui-maven-plugin dependencies, you need to execute command from soapui-maven-plugin project. You can follow the following steps. I assumed you familiar with GIT CLI. If not, you need to manually download from https://github.com/SmartBear/soapui
git clone https://github.com/SmartBear/soapui
cd soapui/soapui-maven-plugin
mvn dependency:copy-dependencies
You can get list of dependencies in soapui/soapui-maven-plugin/target/dependency (total 82files)
[ERROR] Failed to execute goal on project soapui-maven-plugin: Could not resolve dependencies for project com.smartbear.soapui:soapui-maven-plugin:maven-plugin:5.0.0: Could not find artifact javafx:jfxrt:jar:2.2 at specified path (your jdk path)
If you get the above error, it means your maven jdk is version jdk.1.7 (u6 or earlier) which is not installed with javafx. Download newer jdk that comes with javafx at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html . Remember change your maven jdk to this newer jdk.
If you want to use the dependency-plugin you could add the dependencies to the pom...and download with the depepndency-plugin...
It works right for me...
<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>com.ab.forge.utility.copydependenciespom</groupId>
<artifactId>copydependenciespom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<!-- BINARIES -->
<dependencies>
<!--CUSTOMER RETURN -->
<dependency>
<groupId>com.ab...</groupId>
<artifactId>customerret.....</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<overWriteIfNewer>true</overWriteIfNewer>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeGroupIds>com.ab.ah.scad.acl</excludeGroupIds>
<excludeTypes>pom</excludeTypes>
<includeGroupIds>com.ab.oneleo</includeGroupIds>
<outputDirectory>${outputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
After I just run the install passing the -DoutputDirectory parameter....
Try this...
To view all the plugin dependencies you can run a dependency:tree on the pom (where the plugin in configured)
Imagine I have this entry in my target file (used as active target in my tycho build):
<location includeAllPlatforms="true" includeMode="slicer" includeSource="true" type="InstallableUnit">
<repository id="orbit_I" location="http://download.eclipse.org/tools/orbit/downloads/drops/I20131203074849/repository/"/>
<unit id="javax.servlet" version="3.0.0.v201112011016"/>
</location>
Can I reference this plugin as maven artifact (to use the maven-dependency-plugin)? What is the groupId/artifactId of the bundle?
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>???</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
<type>???</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
In this example I tried a lot of combination, to replace the ??? with something that make sense.
I get always the same error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-dependency-plugin:2.8:copy (copy) on
project ** Unable to find artifact version of ???:??? in either
dependency list or in project's dependency management. -> [Help 1]
Thanks a lot for your answers.
Tycho injects the bundle dependencies from p2 repositories are into the Maven model with a synthetic groupId p2.eclipse-plugin. Using this groupId and the bundle symbolic name as artifactId, you should be able to reference the p2 dependencies from any Maven plugin.
BTW, you can see the injected dependencies by adding the tree goal of the maven-dependency-plugin, e.g. with mvn clean verify dependency:tree.
I have a Maven project. One of my dependencies is a zip file. Maven downloads this zip file to the local repository but the pom file is not there too. How can I instruct Maven to download also the pom file? the type of my dependency is zip.
the pom file exists in the remote repository.
the pom file:
<modelVersion>4.0.0</modelVersion>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>
<name>art</name>
<version>1-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>createZip.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
the deploy command:
call mvn clean install
call mvn deploy:deploy-file -Durl=url -Dpackaging=zip -Dfile="%~dp0\target\art-1-SNAPSHOT.zip" -DgroupId=com.g.g -DartifactId=art -Dversion=1-SNAPSHOT -DrepositoryId=... -DpomFile="pom.xml"
the dependency:
<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>
<version>1-SNAPSHOT</version>
<type>zip</type>
If you want both the zip and the pom, you may specify them both as dependencies.
<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>
<version>1-SNAPSHOT</version>
<type>zip</type>
<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>
<version>1-SNAPSHOT</version>
<type>pom</type>
Another way to do it if you don't want to specify the pom as a dependency: the Maven dependency plugin has a get mojo that allows downloading of named artifacts from a remote repository.
This could be because the packaging in the pom.xml differs from the packaging of the dependency. While pom.xml has the packaging as pom, the actual dependency packaging is zip.
Try changing the <packaging> in pom.xml to zip and see if addresses the issue.