how to set plugin repository in command line use maven 3 - maven-3

how to set plugin repository in command line use maven 3?
such as:
mvn install -DskipTests=true -Dmaven.pluginRepository.url=http://www.google.com
I tried this configuration, but it didn't work!

Related

Copy all output jars with dependencies into one folder

I've got a parent POM.xml defining 4 modules, 3 of which reference the first one (this project to be precise).
I am trying to copy all output jars with their runtime dependencies into one folder using the following commands:
mvn package
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies
-DoutputDirectory=deps -DincludeScope=runtime
-DexcludeGroupIds=com.acadiasoft.im
The first command succeeds and the last fails with the error:
[ERROR] Failed to execute goal on project simm: Could not resolve dependencies for project com.acadiasoft.im:simm:jar:1.0.0-SNAPSHOT: Could not find artifact com.acadiasoft.im:base:jar:1.0.0-SNAPSHOT -> [Help 1]
Note the last parameter -DexcludeGroupIds=com.acadiasoft.im which is how I tried working around this error. I also tried excludeArtifactIds to the same effect.
Question 1: Why doesn't it work? Why is it not skipping artefacts with group id com.acadiasoft.im?
Question 2: Is there a way to make maven 'see' the the jars produced in the mvn package step and copy them over along with their dependencies?
Version info:
Maven 3.6.1
JDK 1.8
Please note that I would prefer a command line based solution rather than having to modify a POM. Thanks.
working spell is
mvn clean install
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:copy-dependencies -DoutputDirectory=deps -DincludeScope=runtime -DexcludeGroupIds=com.acadiasoft.im
note package -> install

Jar versioning in Jenkins

On each maven build or release, how to get new jar version in Jenkins. I have tried it in Jenkins but only getting same jar file name as it is in pom file.
you can use maven-exec-plugin to print the version to stdout or write it in a file:
mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:exec

Skip first mvn install in travis-ci

I'm having troubles building a project with maven on travis-ci because travis automatically runs
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
which fails because of a timeout:
No output has been received in the last 10 minutes, this potentially
indicates a stalled build or something wrong with the build itself
According to the documentation I should be able to override it defining a custom script in .travis.yml but it does not work, here my configuration:
sudo: false
language:
- java
script: "travis_wait mvn -T4 -pl quickfixj-codegenerator install"
jdk:
- oraclejdk8
env:
- MAVEN_OPTS="-Xms2048m -Xmx=2048m"
branches:
only:
- travis-ci-build
Is there any way to avoid the automatic mvn install or to tweak it ?
This is mentioned in the documentation:
https://docs.travis-ci.com/user/job-lifecycle/#skipping-the-installation-phase
Skip the installation step entirely by adding the following to your .travis.yml:
install: skip
The install step runs before script step, and with Maven you don't usually need the install step, at least I personally haven't ever found it useful — Maven will download dependencies on script step anyway.
I had the same issue. It was solved after some discussion with the Travis CI support. Here is their response:
That maven command is run as part of the install section of your
build, it's the default.
If you want to skip this step, you can override it by adding this to
your .travis.yml file:
install: /bin/true
I have found it useful to have an install: mvn dependency:resolve step that downloads the build dependencies up front, so that the output of the actual build script is kept clean

Jenkins: how can I add -D parameter to the build?

How can i make Jenkins do the following:
When i create a WAR file i normally run the following command:
mvn clean install -Dapp.env=SOME_ENVIRONMENT
Which loads the specific properties for that environment. I've added a build parameter in Jenkins, but this has had no effect.
When you add a new job or modifying an existing job you can put this directly into Goals and options under 'Build':
clean install -Dapp.env=SOME_ENVIRONMENT

create POM with junit 4

I use Maven 3.0.4 and want to have junit 4 by default.
My projects are created with the command :
$>mvn archetype:create -DgroupId=my.group.id -DartifactId=myArtifactId -DpackageName=my.package.name
This puts a depency to junit version 3.8.1 in the created pom.xml, dispite the fact that verion 4.8.1 is already present.
There are no dependencies to junit in my global settings.xml, and I haven't a local .m2/repository/settings.xml. I don't want to remove the old version 3.8.1., but want that all new projects are created with version 4.8.1
Can I do this in my settings.xml (global or local does not matter)? And if so what is the correct syntax?
A couple things:
archetype:create is deprecated by archetype:generate; please use generate, it's interchangeable with create in your example.
As for a solution, I'd say the simplest thing to do is generate your project, edit the pom to have the correct junit version; and then from within your project run:
mvn archetype:create-from-project
Which will create an archetype based on your modifications, you simply need to install this with:
cd target/generated-sources/archetype/
mvn install
Now you can create new maven projects with this new archetype as you like with:
mvn archetype:generate -DgroupId=my.group.id -DartifactId=newArtifact -DpackageName=my.package.name -DarchetypeArtifactId=myArtifactId-archetype -DarchetypeGroupId=my.group.id
Hopefully this helps.

Resources