Trying to copy denedecy bot not working - maven

<modelVersion>4.0.0</modelVersion>
<artifactId>eau-claims-jar</artifactId>
<groupId>com</groupId>
<name>eau-claims-jar</name>
<packaging>jar</packaging>
<version>2.1.10.0-TIM3-SNAPSHOT</version>
<profiles>
<profile>
<id>build-4-eau</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<!-- <version>2.10</version> -->
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com</groupId>
<artifactId>kcaps</artifactId>
<version>2.3.0.0-TIM2-SNAPSHOT</version>
<!-- <type>jar</type> -->
</artifactItem>
</artifactItems>
<outputDirectory>.</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Dependent kcaps jar is not getting downloaded. I am trying to build a jenkins job that downloads the dependent jar and copy to the server. Only eau-claims-jar jar is getting generated and copied but the dependent jar is not. any idea what i am doing wrong or any different approach?

http://www.egtry.com/tools/maven/dependency_copy
Tried how its in above link and it worked. still don't understand what was the issue with my pom.xml

Related

Inconsistent behaviour between maven-surefire and tycho-surefire, with jacoco not generating reports

I'm working on creating a pom for a project and adding test cases to it. The project is an eclipse plugin.
Compiling the project with tycho works just fine, the only problem is during testing:
If I run both maven-surefire-plugin tests and tycho-surefire-plugin-tests, the former performs all the tests as expected, while the latter gives the following error:
Execution test of goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test failed: Tycho build extension not configured for MavenProject
I would be perfectly fine to just add <skipTests>true</skipTests> to the tycho-surefire-plugin while keeping maven-surefire-plugin on; the problem is even that way, jacoco refuses to create the coverage site, with the following (non error) message:
Skipping JaCoCo execution due to missing execution data file.
I tried to look for solutions of both, but any combination of the solutions I found doesn't lead me to having a working coverage site.
Maven really makes me quite confused, especially with tycho around, so I'd apreciate any explanation on top of the actual fix.
Here is my pom:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroupid</groupId>
<artifactId>myartifactid</artifactId>
<name>myname</name>
<packaging>eclipse-test-plugin</packaging>
<properties>
<tycho-version>1.7.0</tycho-version>
</properties>
<parent>
<groupId>parentgroupid</groupId>
<artifactId>parent</artifactId>
<version>0.9.5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/java/</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/Test_*.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/Test_*.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<configuration>
<output>file</output>
<append>true</append>
<includes>
<include>**/path_to_source/**/*</include>
</includes>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here is my parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>parentgroupid</groupId>
<artifactId>parent</artifactId>
<version>0.9.5</version>
<packaging>pom</packaging>
<modules>
<module>moduleid</module>
</modules>
<properties>
<tycho-version>1.7.0</tycho-version>
</properties>
<repositories>
<repository>
<id>eclipse-2020-06</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/2020-06</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
<configuration>
<includeAllDependencies>true</includeAllDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
Of course there won't be any test result for the JaCoCo due to you are using very old Surefire version 2.12.4. This version was not created for JUnit5.
Use the latest version 3.0.0-M5 and see the tutorial.
If you want to have tiny POM, remove the dependency junit-jupiter-engine due to you do not need to have an access to the JUnit internals in your test code. The Surefire will download it shortly before the test runtime.
Your POM has several errors. Let's start with the root cause and then other priorities from high to low.
Whole problem is that Surefire does not know about JaCoCo. You have to tel "him" this way (see jacoco.agent) which "wires" both. Pls ead the documentation in the JaCoCo project:
<properties>
<jvm.args.tests>-Xmx2048m -Xms1024m -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</jvm.args.tests>
<properties>
...
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
</configuration>
...
The next error is with the way how you use plugins. The plugin jacoco-maven-plugin must be used only in the plugins section. The problem is that you use it also in the dependencies section. You do not want to have it on the classpath. It is job of the property jacoco.agent to put the jacoco agent on the test classpth only but there the JaCoCo plugin must start before the Surefire plugin.
The next thing i do not understand is the config of the compiler. Why you have this?
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
I have second question regarding the packaging. I have never seen this one. It isn't a standard packaging.
<packaging>eclipse-test-plugin</packaging>
Has the Eclipse plugin any special binary form of the archive file?

How to include files that are built (during build) in the built jar?

This might be dumb (please guide me), but I'm trying to include some binaries from a dependency in my package using Maven.
The dependency is jinput, and the binaries are "unpacked" during build. Since the binaries are unpacked after the build, they're not included in my .jar using the standard "resources"-way of including files. How can I make Maven include the binaries in my package when they aren't present during the build?
<?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>
<groupId>com.mycompany</groupId>
<artifactId>ProjectA</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Unpack the jinput binaries to "bin" -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack jinput windows</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<skip>false</skip>
<artifactItems>
<artifactItem>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.7</version>
<classifier>natives-windows</classifier>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>/bin</outputDirectory>
<includes>**/*.dll</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.builddir}</directory>
<includes>
<include>bin/*.dll</include>
</includes>
</resource>
</resources>
</build>
</project>
Instead of resources, you can use maven-jar-plugin.
I've tested the below code and it works fine.
<properties>
<my.dll.folder>${project.build.directory}/unpackedfiles</my.dll.folder>
</properties>
<dependencies>
<dependency>
<groupId>net.java.jinput</groupId>
<artifactId>jinput</artifactId>
<version>2.0.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>net.java.jinput</groupId>
<artifactId>jinput-platform</artifactId>
<version>2.0.7</version>
<classifier>natives-windows</classifier>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${my.dll.folder}/bin</outputDirectory>
<destFileName>optional-new-name.jar</destFileName>
<includes>**/*.dll</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${my.dll.folder}</classesDirectory>
<classifier>sample</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Once your pom file is modified with above code, you can execute below command
mvn clean package
Then you can verify that the resulting jar file contains the required *.dll files in bin folder.
You can remove the <classifier> tag if you want to overwrite the same output jar file.

maven-deploy-plugin not executing its execution

I need to deploy custom jar's from my project itself I overrides maven-deploy-plugin with two more execution with its default execution. below are my pom.xml with distributionManagement and maven-deploy-plugin which I use for my deployment.
<groupId>mycompany</groupId>
<artifactId>myproject</artifactId>
<packaging>jar</packaging>
<distributionManagement>
<repository>
<id>temp</id>
<name>Release Repository</name>
<url>http://localhost:8000/nexus/content/repositories/temp/</url>
</repository>
</distributionManagement>
<dependencies>
<dependency>
some dependency
</dependency>
<dependency>
some dependency
</dependency>
<dependency>
some dependency
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
<execution>
<id>myjar-one</id>
<phase>deploy</phase>
<configuration>
<repositoryId>temp</repositoryId>
<url>http://localhost:8000/nexus/content/repositories/temp/</url>
<packaging>jar</packaging>
<artifactId>myjar-one</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<sources>${project.build.directory}/build/lib/myjar-one.jar</sources>
</configuration>
</execution>
<execution>
<id>myjar-two</id>
<phase>deploy</phase>
<configuration>
<repositoryId>temp</repositoryId>
<url>http://localhost:8000/nexus/content/repositories/temp/</url>
<packaging>jar</packaging>
<artifactId>myjar-two</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<sources>${project.build.directory}/build/lib/myjar-two.jar</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Guys I figure out the issue, there are following thing I need to fix.
Need to add goal.
Need to use file tag instead of source tag.
So final maven-deploy-plugin looks like.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<executions>
<execution>
<id>default-deploy</id>
<phase>none</phase>
</execution>
<execution>
<id>myjar-one</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>temp</repositoryId>
<url>http://localhost:8000/nexus/content/repositories/temp/</url>
<packaging>jar</packaging>
<artifactId>myjar-one</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}/build/lib/myjar-one.jar</file>
</configuration>
</execution>
<execution>
<id>myjar-two</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>temp</repositoryId>
<url>http://localhost:8000/nexus/content/repositories/temp/</url>
<packaging>jar</packaging>
<artifactId>myjar-two</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>${project.build.directory}/build/lib/myjar-two.jar</file>
</configuration>
</execution>
</executions>
</plugin>
after fixing this issue, my both custom jar's are deployed at my maven repository. Thanks for help

Auto deploy maven project war file in company's server

I have created a maven project in netbeans and there i manually build a war file and upload to server.
My pom file only contains:
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
...
<dependency>
<dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.0-release</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<!--<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>2.9.0</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver>
<jdbcUrl>jdbc:mysql://localhost:3306/login</jdbcUrl>
<jdbcUser>root</jdbcUser>
<packageName>com.titas.model</packageName>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
</plugin>-->
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources/java</outputDirectory>
<processor>com.mysema.query.apt.jdo.JDOAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Now i want to auto deploy war file in company's server whenever i will build in netbeans.
Is there any tag to auto deploy in server in pom.xml? Like if i use any plugin where i will specify my server folder war file will auto deploy there and replace previous one.
Thanks in advance!!
I don't have experience deploying to Tomcat specifically, and apparently it's different based on the version.
Tomcat 6/7
For Tomcat 6 replace "tomcat7" with "tomcat6" in the following lines.
Use the tomcat7-maven-plugin by putting this in the <build><plugins> section of your pom.xml:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://www.example.com:1234/mymanager</url>
</configuration>
</plugin>
Obviously change the url to match the URL of the server/manager you're trying to deploy to. If you need to specify credentials add a <server>servername</server> tag to the configuration block and put this in your maven settings.xml (under path <settings><servers>):
<server>
<id>servername</id>
<username>myusername</username>
<password>mypassword</password>
</server>
For other configuration changes see the plugin page linked above.
Once it's configured you should be able to run mvn package tomcat7:deploy to deploy to your server. Other maven goals are here.
Tomcat 8
The best I'm finding is this question: Tomcat 8 integration with Maven
The accepted answer uses the cargo-maven2-plugin, but looking at how it's configured I don't think that will go to a remote machine.
Alternately you can try the tomcat7 plugin as detailed above, I did see this blog post that suggests it works for 8 too.

Maven install:install-file seems not to work

I've created a Maven project with some dependencies on libraries (.jar files) which are not in Maven central. The internal repository that we had is being taken offline and we have not been authorized to make a new one, so I modified the POM to use install:install-file on each of those files when a certain profile is activated. It seemed to work on my machine, but it's possible it might not have worked because the .jars were already in my repository.
We had a new employee start this week and I was trying to help him install the dependencies by triggering the profile, and although the debug trace lists those goals as being on the plan (and mvn help:active-profiles shows the profile being activated), it doesn't work. The directories are created in the repository, but only a .lastupdated file for the .jar and the .pom are created.
The error we get is that POM could not be found for the given artifact. That's expected since we use <generatePom>true</generatePom> in the plugin's execution.
Any ideas on why this might not work?
Here's the relevant section of the POM:
<profiles>
<profile>
<id>self-contained</id>
<activation>
<property>
<name>installBundledJars</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>installCaseControlUpdateAPI</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/CaseControlUpdateAPI.jar</file>
<groupId>com.west.thomson.contech</groupId>
<artifactId>CaseControlUpdateAPI</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>installMQ</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/com.ibm.mq-5.304.jar</file>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>5.304</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>installMQJMS</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/com.ibm.mqjms-5.304.jar</file>
<groupId>com.ibm</groupId>
<artifactId>mqjms</artifactId>
<version>5.304</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>installJADABAS</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/jadabas.jar</file>
<groupId>com.softwareag</groupId>
<artifactId>jadabas</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>installOJDBC</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/ojdbc14.jar</file>
<groupId>oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10g</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Two possible problems i can think of,
- check if you have the libs in the specified path.
- check permissions on the .m2 repo and the project location where you are running mvn cmd.

Resources