When i exeute:
mvn -Dparam.version=9 help:effective-pom | clip
in the command line on Windows 10 i get all over this clip only:
<properties>
<param.version>4</param.version>
</properties>
which is the old version.
How can i force to change this param?
In the cmd:
mvn --version
Apache Maven 3.5.4
Froms poms:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
EDIT:
I use this property to set depedency version for example:
<dependency>
<groupId>x</groupId>
<artifactId>c-api/artifactId>
<version>${param.version}</version>
</dependency>
inside c-api we can see:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>x</groupId>
<artifactId>c</artifactId>
<version>4</version>
</parent>
<artifactId>c-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>x</groupId>
<artifactId>c-api</artifactId>
</dependency>
<dependency>
<groupId>x</groupId>
<artifactId>p-api</artifactId>
</dependency>
<dependency>
<groupId>x</groupId>
<artifactId>f-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
First, you need use -Dparam.version instead -dParam.version.
If
<properties>
<param.version>4</param.version>
</properties
is defined in the xxx.pom file, you are not allowed to change it using command line, while you are free to override it. And in this case, though the value is still 4 in the pom file, others which refer it by ${param.version} will pick 9.
You are looking in the incorrect place when checking if your command line parameter has been correctly applied.
If you entered the command mvn -Dparam.version=9 help:effective-pom then you should see your dependency version evaluated correctly.
Where your pom has
...
<dependency>
<groupId>x</groupId>
<artifactId>c-api</artifactId>
<version>${param.version}</version>
</dependency>
...
the output of the command will display
...
<dependency>
<groupId>x</groupId>
<artifactId>c-api</artifactId>
<version>9</version>
</dependency>
...
If you just run mvn help:effective-pom you will see
...
<dependency>
<groupId>x</groupId>
<artifactId>c-api</artifactId>
<version>4</version>
</dependency>
...
with the version specified in the pom properties displayed instead.
Related
I try to test my maven plugin and receive weird exception. Found similar question here, but the answer didn't help.
pom.xml
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>3.0-alpha-2</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aether</artifactId>
<version>0.10.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-compat</artifactId>
<version>3.3.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
Test class:
public class ConverterMojoTest {
#Rule
public MojoRule rule = new MojoRule() {
#Override
protected void before() throws Throwable {
super.before();
}
#Override
protected void after() {
super.after();
}
};
#Rule
public TestResources resources = new TestResources();
#Test
public void testExecute() throws Exception {
File project = resources.getBasedir("valid");
File pom = new File(project, "pom.xml");
Assert.assertNotNull(pom);
Assert.assertTrue(pom.exists());
ConverterMojo mojo = (ConverterMojo) rule.lookupMojo("convert", pom);
Assert.assertNotNull(mojo);
mojo.execute();
}
}
Test project 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>com.my.utils.test</groupId>
<artifactId>project-to-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test</name>
<build>
<plugins>
<plugin>
<groupId>com.my.utils</groupId>
<artifactId>converter-maven-plugin</artifactId>
<configuration>
</configuration>
</plugin>
</plugins>
</build>
</project>
Exception:
org.codehaus.plexus.component.repository.exception.ComponentLookupException: java.util.NoSuchElementException
role: org.apache.maven.plugin.Mojo
roleHint: com.my.utils:converter-maven-plugin:1.0.0-SNAPSHOT:convert
I was facing this issue in one of the modules that had proper execution configuration with the appropriate goal. I resolved this by simply running mvn clean install in that specific module (without deleting anything from the local repo).
Your test project's pom.xml needs to have the an <execution/> section with the respective <goal/>:
<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.my.utils.test</groupId>
<artifactId>project-to-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Test</name>
<build>
<plugins>
<plugin>
<groupId>com.my.utils</groupId>
<artifactId>converter-maven-plugin</artifactId>
<configuration>
...
</configuration>
<executions>
<execution>
<goals>
<goal>convert</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Otherwise, the testing harness will fail to understand what it has to map and load.
Just update the maven project and mvn clean install. It will work
I had the same issue, followed all of the advice but still had the issue. I solved it by clearing out my local repo then doing a mvn clean install -DskipTests from terminal. Then I ran my jUnit test from Eclipse and it worked. Must have been a conflicting dependency somewhere.
open your location
File | Settings | Build, Execution, Deployment | Build Tools | Maven
Change "maven home path:" to Use Maven wrapper here. This is how my problem was solved.enter image description here
Currently I am moving from karaf 3.0.5 to the newest version 4.0.2, I do assembly my own karaf with the karaf-maven-plugin. This is how my pom looks like.
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<groupId>my.own.group</groupId>
<artifactId>assemble</artifactId>
<version>1.14.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>karaf-customize</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>karaf-assembly</packaging>
<dependencies>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>framework</artifactId>
<version>${karaf.version}</version>
<type>kar</type>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>standard</artifactId>
<classifier>features</classifier>
<version>${karaf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf.karaf</groupId>
<artifactId>apache-cxf</artifactId>
<classifier>features</classifier>
<version>${cxf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>enterprise</artifactId>
<classifier>features</classifier>
<version>${karaf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>my.own.group</groupId>
<artifactId>kar-archive</artifactId>
<version>1.14.0-SNAPSHOT</version>
<type>pom</type>
<optional>true</optional>
</dependency>
<dependency>
<groupId>my.own.group</groupId>
<artifactId>karaf-branding</artifactId>
<version>1.14.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.alutam</groupId>
<artifactId>ziputils</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<javase>1.8</javase>
<bootFeatures>
<feature>jasypt-encryption</feature>
<feature>config</feature>
<feature>standard</feature>
<feature>region</feature>
<feature>management</feature>
<feature>bundle</feature>
<feature>package</feature>
<feature>kar</feature>
<feature>ssh</feature>
<feature>http</feature>
<feature>cxf</feature>
<feature>service-wrapper</feature>
<feature>jdbc</feature>
<feature>system</feature>
</bootFeatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
With this configuration I do get the following error for several dependencies.
Caused by: org.osgi.framework.BundleException: Unsupported 'Bundle-ManifestVersion' value: 1
at org.apache.karaf.features.internal.resolver.ResourceBuilder.doBuild(ResourceBuilder.java:88)
at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:78)
I guess it happens within this parser. The reason is some old third party libraries have only Bundle-ManifestVersion: 1 set within their manifest file.
With karaf-maven-plugin 3.x this didn't matter at all. In contrast the karaf-maven-plugin 4.x fails with message above.
The only way I know to fix this is either rebuild from source or repack the hole jar again.
Is there any other way like a configuration for the karaf-maven-plugin to disable this constraint check? Because it would be awful lot of work to get all of this bundles up an running, again.
I faced the same error when updating to Karaf 4 and you have two choices:
Osgify conflictive dependency using bndtools:
Download bnd tools
Open a shell where you have downloaded bnd-2.4.0.jar.
Type:
java -jar bnd-2.4.0.jar wrap -o osgify-dependency.jar dependency.jar
where dependency.jar is your third party and osgify-dependency.jar will be the output.
Deploy to maven repo overriding the previous maven coordinates, or deploy your thirdparty with different coordinates.
mvn deploy:deploy-file -Dfile osgify-dependency.jar ..
Enable the wrap protocol
Add to you maven karaf plugin wrap and wrapper features.
So you can use wrap protocol to fix your corrupted MANIFEST.MF
Inside some karaf features:
<bundle>wrap:mvn:group.id/third.party.artefact.id/version</bundle>
Inside your pom.xml notice feature wrap / wrapper.
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
</executions>
<configuration>
<!-- no startupFeatures -->
<bootFeatures>
<feature>feature</feature>
<feature>jaas</feature>
<feature>shell</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>bundle</feature>
<feature>config</feature>
<feature>deployer</feature>
<feature>diagnostic</feature>
<feature>instance</feature>
<feature>kar</feature>
<feature>log</feature>
<feature>package</feature>
<feature>service</feature>
<feature>system</feature>
<feature>wrap</feature>
<feature>aries-blueprint</feature>
</bootFeatures>
<installedFeatures>
..
<feature>wrapper</feature>
</installedFeatures>
</configuration>
</plugin>
Here you have the full code where i tested:
https://github.com/antoniomaria/gazpachoquest/blob/master/karaf-assembly/pom.xml
I'm using Jenkins to run some testNG test, when the build is finished i get the following message at the end:
[INFO] Build failures were ignored.
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/test-output/testng-result.xml
Did not find any matching files.
Finished: SUCCESS
I looked at the workspace in Jenkins and there is no folder named test-output, the question here is, how do I tell jenkins to create the folder with the results in there?
Here is my pom.xml if needed:
<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.barco.automation</groupId>
<artifactId>barcoAutomation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>barcoAutomation</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!-- added -->
</properties>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.uncommons</groupId>
<artifactId>reportng</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.10-FINAL</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</dependency>
</dependencies>
<build>
<finalName>My Automated tests</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thanks
you need to add post-build action in jenkins to add relative path of the testng-result.xml which can be found in your workspace.
I will recommend you to use HTML Report Publisher Plugin in Jenkins addon and configure your reports as below. This will allow you to view the report for every build. Through this you will be able to archive all your testNG reports build wise and it can be seen on the Job level as well. Once you are installing this plugin, configure your job and add a POST-BUILD-STEP (to enable the HTML REPORT PUBLISHER) and follow the location setting for testNG reports. Please refer to the screenshot below and let me know in case of any questions. Hope this helps!
Typically, your TestNG reports generated here :
<Jenkins-Location>\jobs\<JOB_NAME>\workspace\target\html
I'm creating a apklib from sliding menu because I couldn't find any maven repository. The problem is that when I try from intellij, It imports the library but doesn't add the dependencies to sliding menu library and I have to add it manually.
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.slidingmenu</groupId>
<artifactId>library</artifactId>
<version>1.2</version>
<type>apklib</type>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>com.google.android.maps</groupId>
<artifactId>maps</artifactId>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v13</artifactId>
<version>r12</version>
</dependency>
<dependency>
<groupId>com.github.rtyley</groupId>
<artifactId>roboguice-sherlock</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.2.0</version>
<type>apklib</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
I create the zip, according to the instructions on maven plugin and then I push it to ~/.m2 with this command:
mvn org.apache.maven.plugins:maven-install-plugin:2.4:install-file -DgroupId=com.slidingmenu -DartifactId=library -Dfile=sliding-menu.apklib -Dversion=1.2 -Dpackaging=apklib
You need to install com.slidingmenu in your local repository with mvn clean install instead of install:install-file
mvn clean install will put all the meta-data and the dependencies required by maven in your local repository (i.e. ~/.m2/repository).
In your apk, specify the artifact com.slidingmenu as a dependency of type apklib
I hope it will solve your problems.
Something has gone wrong with my pom and I have a blank dependency and artifactId in the xml but get the same error whether I delete the tags or not.
I am using eclipse with m2eclipse installed in my home folder on Linux Mint 14 with maven version 'Apache Maven 2.2.1 (rdebian-8)' installed
Here is the 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>TransferHandler</groupId>
<artifactId>TransferHandler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.4.6-rc1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.2</version>
<classifier>ftp</classifier>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<artifactId></artifactId>
</dependency>
</dependencies>
</project>
There are three error messages displayed:
On line1:
Multiple annotations found at this line:
- null (org.apache.maven.plugins:maven-resources-plugin:2.5:resources:default-resources:process-resources)
- null (org.apache.maven.plugins:maven-resources-plugin:2.5:testResources:default-testResources:process-test-
resources)
On line70:
Multiple annotations found at this line:
- Project build error: 'dependencies.dependency.groupId' for null::jar is
missing.
- Project build error: 'dependencies.dependency.version' for null::jar is
missing.
On line 71:
Project build error: 'dependencies.dependency.artifactId' for null::jar is missing.
It seems like the one on line 70 with the empty tags is the root cause (excerpt below) but I'm not sure.
<dependency>
<artifactId></artifactId>
</dependency>
Even if I delete the empty tags from the xml and refresh maven and the project the error remains. On my Dependencies tab I see a jar with a '?' next to it but can't delete it and in my Dependency Hierachy tab I see a ' : [compile]' jar but can delete or exclude it.
How can I remove this ghost/null jar?
Try This Header
<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/maven-v4_0_0.xsd">
Good Luck !
I found a way around the problem using git but was not able to solve it directly by removing the offending packages.
The work-around was to shutdown eclipse, remove the pom and then use git to discard changes in the working directory. Commands:
rm pom.xml
git checkout -- pom.xml
Then the pom should reappear returned to its state at the last commit (which luckily for me was before this error arose). Not a very satisfying answer but at least it worked. If anyone posts an answer and explanation to the heart of the real problem (ie why can't I remove a null package and how did it get there in the first place) I would still be happy to accept it.