Maven install:install-file seems not to work - maven

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.

Related

How to run embedded Tomcat 9 inside Maven 3 for integration testing purposes?

I am trying to run embedded Tomcat 9 inside Maven 3 for integration testing purposes. I was led to cargo-maven2-plugin by other SO answers.
So, attempting to follow the instructions found here:
https://codehaus-cargo.github.io/cargo/Static+deployment+of+WAR.html
I have this fragment in a simple POM:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<type>war</type>
<properties>
<file>path/to/myapp.war</file>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
Which I try to execute with mvn org.codehaus.cargo:cargo-maven2-plugin:run
It fails with the error:
[INFO] [en2.ContainerRunMojo] Resolved container artifact
org.codehaus.cargo:cargo-core-container-tomcat:jar:1.7.6 for container
tomcat9x [WARNING] The defined deployable has the same groupId and
artifactId as your project's main artifact but the type is different.
You've defined a [war] type wher eas the project's packaging is [pom].
This is possibly an error and as a consequence the plugin will try to
find this deployable in the project's dependencies.
How can I make this work? I just want to launch the given WAR in an embedded tomcat9, from within Maven.
After trying many permutations, this finally worked for me:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.9</version>
<configuration>
<container>
<systemProperties>
<myvar1>${myEnvVar}</myvar1>
<myvar2>... stuff ...</myvar2>
</systemProperties>
<containerId>tomcat9x</containerId>
<zipUrlInstaller>
<url>https://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat/9.0.29/tomcat-9.0.29.zip</url>
</zipUrlInstaller>
</container>
<deployables>
<deployable>
<groupId>org.codehaus.cargo</groupId>
<artifactId>simple-war</artifactId>
<type>war</type>
<location>path/to/myapp.war</location>
<properties>
<context>myapp</context>
</properties>
</deployable>
</deployables>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
Use the failsafe plugin to automatically run the Integration Tests between the start and stop:
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
</configuration>
</execution>
</executions>
</plugin>

How to run multiple jmeter .jmx tests with multiple input files using jmeter.maven.plugin

I need to be able to run jmeter tests from jenkins using mvn and jmeter-maven-plugin.
Here is the file setup:
test_dev.jmx
test_dev.txt
test_dev_regression.jmx
test_dev_regression.txt
Here is the pom file used by the mvn command (below):
<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.example</groupId>
<artifactId>JmeterTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JMeter Example </name>
<properties>
<input.jmx.folder>${project.basedir}/src/test/jmeter</input.jmx.folder>
<input.jmx.file>test_${Environment}.jmx</input.jmx.file>
<input.csv>${project.basedir}/src/test/jmeter/test_${Environment}.txt</input.csv>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.9.0</version>
<configuration>
<propertiesUser>
<threadgroup00.dataFile>${input.csv}</threadgroup00.dataFile>
</propertiesUser>
<testFilesIncluded>
<!-- If spcified, only particular file will be processed. -->
<jMeterTestFile>${input.jmx.file}</jMeterTestFile>
</testFilesIncluded>
<testResultsTimestamp>false</testResultsTimestamp>
<!-- This will pick up all the jmx file at below folder. -->
<testFilesDirectory>${input.jmx.folder}</testFilesDirectory>
<generateReports>true</generateReports>
<resultsFileFormat>csv</resultsFileFormat>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>test</phase>
<goals>
<goal>jmeter</goal>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And here is the command we are using to run the tests:
mvn verify -DEnvironment=$TEST_ENVIRONMENT
As you can see, currently there are no regression tests being run. I'd like to add the regression test and it's input file into this pom so that both tests get run one after the other. The hang-up for me is the <threadgroup00.dataFile> property. What needs to be specified here to use another input file for the regression test? Or is there another way to run multiple tests with multiple inputs using this framework?
Thanks in advance!
As of version 3.0.0 you should now be able to do this, an example execution block showing the setup is:
<executions>
<execution>
<id>configuration-one</id>
<goals>
<goal>configure</goal>
</goals>
<configuration>
<resultsFileFormat>xml</resultsFileFormat>
</configuration>
</execution>
<execution>
<id>configuration-two</id>
<goals>
<goal>configure</goal>
</goals>
<configuration>
<resultsFileFormat>csv</resultsFileFormat>
</configuration>
</execution>
<execution>
<id>performance test one</id>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<selectedConfiguration>configuration-one</selectedConfiguration>
<testFilesIncluded>
<jMeterTestFile>test1.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
<execution>
<id>performance test two</id>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<selectedConfiguration>configuration-two</selectedConfiguration>
<testFilesIncluded>
<jMeterTestFile>test2.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
</executions>
The IT test showing this behaviour (Which the above execution example was taken from) is available at here.

Maven: how to exec a pom twice with different profiles?

I want to make a build with Maven within a pom which can be built with two different profiles.
In other words, my task is to force the build in order that the build produces two different builds in the target folder as like I will execute "maven install -P" two times.
So, to be more clear:
one single invocation
two different results based on the profile associated in that time
I've tried the exec-maven-plugin but I'm not sure if is the correct way, because it's not doing what I desire.
How can I perform that?
Here's the pom I'm trying.
The tasks are:
copy resources from another project
replace content based on the profile
Build both profiles.
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>
<artifactId>MavenDoubleInstallation</artifactId>
<profiles>
<profile>
<id>profileA</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>profileA</env>
<token>/path/for/profileA</token>
</properties>
</profile>
<profile>
<id>profileB</id>
<properties>
<env>profileB</env>
<token>/path/for/profileB</token>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/classes/${env}/result</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/../SourceProject/resources/result</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${basedir}/target/classes/${env}/result</basedir>
<includes>
<include>**/*.sh</include>
</includes>
<replacements>
<replacement>
<token>%%TOKEN%%</token>
<value>${token}</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>build-profileA</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileA -X</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>build-profileB</id>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>maven</executable>
<arguments>
<argument>-P profileB -X</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Trying to copy denedecy bot not working

<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

How to use master pom file to checkout all modules of a web application and build all modules

I have a web application that relies on several modules. So to build it, I have a master pom.xml file. What I want this pom file to do is to checkout out all the modules.
below is my pom file.
<executions>
<execution>
<id>check-out-project1</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
<configuration>
<checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
<connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
<!--<developerConnection>scm:svn:svn://svnserver/svn/module1/trunk</developerConnection>!-->
<username>username</username>
<password>password</password>
</configuration>
</execution>
<execution>
<id>check-out-project2</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
<configuration>
<checkoutDirectory>${project.build.directory}/module1</checkoutDirectory>
<connectionUrl>scm:svn:svn://svnserver/svn/module1/trunk</connectionUrl>
<username>username</username>
<password>password</password>
</configuration>
</execution>
</executions>
I have tried mvn scm:checkout and mvn scm:checkout -check-out-project1 but it give me the error:
Cannot run checkout command : Can't load the scm provider. You need to define a connectionUrl parameter.
I don't understand why this is happening since I have the connectionUrl parameters defined inside the pom file already,the ideas point that I want to get to is having the pom file configured to be able to checkout multiple projects at the same time. Please let me know what I am doing wrong here, Thanks in Advance.
I found that if placing each of the checkouts into its own <execution> ... </execution> and within place the individual <configuration> ... </configuration> for them works. For example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<executions>
<execution>
<id>repo1-dependency</id>
<phase>generate-sources</phase>
<configuration>
<connectionUrl>${my.repo1.url}</connectionUrl>
<scmVersion>${my.repo1.branch}</scmVersion>
<scmVersionType>branch</scmVersionType>
<checkoutDirectory>${project.build.directory}/${my.repo1}-${my.repo1.branch}</checkoutDirectory>
</configuration>
<goals>
<goal>checkout</goal>
</goals>
</execution>
<execution>
<id>repo2-dependency</id>
<phase>generate-sources</phase>
<configuration>
<connectionUrl>${my.repo2.url}</connectionUrl>
<scmVersion>${my.repo2.branch}</scmVersion>
<scmVersionType>branch</scmVersionType>
<checkoutDirectory>${project.build.directory}/${my.repo2}-${my.repo2.branch}</checkoutDirectory>
</configuration>
<goals>
<goal>checkout</goal>
</goals>
</execution>
</executions>
</plugin>
I faced to same situation and I found a solution -using your code :D- that works on my computer:
<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>de.xxx.internet</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://www.mySite.de</url>
<scm>
<connection>scm:svn:http://svn-repo-adress:8080/repo/myDirectory</connection>
<developerConnection>http://svn-repo-adress:8080/repo/myDirectory</developerConnection>
<tag>HEAD</tag>
<url>http://svn-repo-adress:8080/repo/myDirectory</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.6</version>
<configuration>
<goals>checkout</goals>
<checkoutDirectory>target/checkout</checkoutDirectory>
<username>username</username>
<password>userpassword</password>
</configuration>
<executions>
<execution>
<id>check-out-project1</id>
<phase>generate-sources</phase>
<goals>
<goal>checkout</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
After I executed "mvn scm:checkout" on the cmd console it did work.
I think the important point was to add the scm tag first, before I had executed the build tag.

Resources