How do i skip the license check when running the maven install? - maven

I ran a mvn clean install on a big Java project that I work on, but it kept failing due to some files not having the proper license headers. Well, thats not my concern right now, how do I skip that? the actual error i am seeing is,
Failed to execute goal org.codehaus.mojo:license-maven-plugin:1.14:add-third-party (default) on project test-project: There are some dependencies with no license, please fill the file /Users/test-project/src/license/THIRD-PARTY.properties
I also tried this maven command, but it didn't work
mvn clean install -Dlicense.skip=true

Try skipping AddThirdParty mojo with -Dlicense.skipAddThirdParty=true.

In my case, it worked with just -Dlicense.skip, without =true.
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>3.0</version>
</plugin>

I found this helpful
$ mvn license:help -Ddetail | fgrep skip
which gave me
-Dlicense.skipDownloadLicenses
you don't need to add =true because just defining it is enough.

This one works for me
-Dlicense.skipCheckLicense

Related

Unable to create maven package for AEM due to use of data-sly-set

When attempting to create a package for my ui.apps folder with maven I receive this error
data-sly-set: None of the registered plugins can handle the
data-sly-set block element.
I am indeed using the data-sly-set property like so
<sly data-sly-set.index="${mylist.count}"></sly>
And it does work on my local instance it just fails validation when packaging it.
I noticed that htl-maven-plugin was on version 1.0.6 if that is related.
The issue was that the version of htl-maven-plugin was too old. I resolved this issue by going into pom.xml and added
<version>1.3.4-1.4.0</version>
underneath
<artifactId>htl-maven-plugin</artifactId>
It ended up looking like this
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>htl-maven-plugin</artifactId>
<version>1.3.4-1.4.0</version>
</plugin>
After that it I ran
mvn -PautoInstallPackage clean install
and it built successfully. I also ran
mvn versions:display-plugin-updates
earlier to force it to update but I'm not entirely sure if that was necessary.

Install fails in maven, but succeeds in IntelliJ directly

I have a project with many modules that compiles fine in intellij.
When I try to build it in maven (via clean install) I get "COMPILATION ERROR : " and many problems on a specific module, that on IntelliJ are just fine.
I tried restarting Intellij (and cleaned the caches), I tried to uninstall it and reinstall it, tried to uncheck and check reimport automatically, tried reimporitng all the projects, and building and installing them all (and succeeded), updating the repository path, tried to install new maven (3.6 instead of 3.3), and even tried to run maven via the terminal - all that didn't help.
EDIT: I even tried cleaning maven's cache like in here, but failed.
Maven clean succeeds.
I use mac.
So basically my project works, maven doesn't. What could be the problem?
The problem was that the project I included was a spring boot project, and that made maven confused (but unfortunately, IntelliJ was ok with it).
Adding this fixed the problem:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>

Eclipse maven-jar-plugin not signing, because of duplicate entries pom.xml and pom.properties only on Windows

I searched a lot, but I have not found any solution for this.
Environment
*** Eclipse Java EE IDE for Web Developers. Version: Kepler Release - Build id: 20130614-0229 with m2e-wtp - Maven Integration for WTP
1.0.0.20130612-1742
*** Windows 7 up to date
*** Java SDK 1.7.0-40
*** Maven: Embedded (3.0.4/1.4.0.20130531-2315)
Problem
Errors:
Signing jars with (apache)maven-jar-plugin:2.4:sign (signing) on Linux works fine! The same maven project on Windows leads to the following error:
[INFO] jar is unsigned. (signatures missing or not parsable)
[ERROR] jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry: META-INF/maven/.../pom.xml
Other messages:
I spotted different outputs between Linux and Windows from (apache)maven-jar-plugin:2.4:jar (default-jar)
Linux-Eclipse skips both files, because were already added:
...
[INFO] META-INF/maven/com.xyz/abc-client/pom.xml already added, skipping
[INFO] META-INF/maven/com.xyz/abc-client/pom.properties already added, skipping
...
after that the signing works fine!
The Windows ouput is not showing these two lines!!
Additional Information:
I can not use the (apache)maven-jarsigner-plugin, because it will lead to following error - without solution:
[ERROR] jarsigner: cannot rename file jarfile.jar to .orig`
This github-forum website tells me that the m2e-wtp-plugin of
Eclipse causing the problem, and that I should use maven on command
line .... this is the absolutely last option to use!!!
There is also a bug "MPIR-286" on codehouse for this, but still unresolved.
The clean part is done by the plugin and it's the same configuration for a client-module build before the one causing the problem.
Question:
Is there a possibility to get rid of this error? I cannot use the jarsigner-plugin, because of the "rename"-error and not the jar-plugin, because of the "duplicate entry"-error ... that is in fact a very strange situation.
This is the solution by the question's author, moved to the appropriate section.
To question's author: if you want to gain reputation, feel free to write a new answer, then ping me to remove this answer.
So I found it out myself. Here is what helped me to fix the problem.
Research
I found this question after more research and they stated, that the maven.archiver is the cause, because it wants to create the both files after they have been copied into the jar from m2e.mavenarchiver-plugin.
"... the m2e.mavenarchiver is creating pom.xml files etc. in the target directory, then these get pulled in by the maven archiver maven plugin, which then also creates its own files - hence the duplicates."
So the solution is also stated on this topic site.
Solution
Add
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
to your pom.xml
In my case
maven clean install fixed this issues
Make use of this Java Decompiler
for Viewing the jar whether it has a Duplicate pom.xml and properties
I have added below plugin that worked :
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>

how to make a jar in maven? [duplicate]

This question already has answers here:
Making Maven run all tests, even when some fail
(5 answers)
Closed 3 years ago.
Actuality when i run tests they fails but i need to run them to get some .class files which are very important for my jar.
By default when test results fails , the jar is not build , could i add a setting in pom.xml which ignore that, so I can build the jar ignoring results from tests ?
I read something about "Maven Surefire Plugin" but I don't know how to use it...
Please refer to surefire:test for details, but the most useful properties are:
-Dmaven.test.failure.ignore=true (or -DtestFailureIgnore=true) - will ignore any failures occurred during test execution
-Dmaven.test.error.ignore=true ( deprecated ) - will ignore any errors occurred during test execution
-DskipTests - would compile the test classes but skip test execution entirely
-Dmaven.test.skip=true - would not even compile the tests
I believe that in your case where you want to compile test classes but not fail the build due to any tests errors and still create the jar.
You should use the first option to ignore any test failures which you can still review once the build has finished.
mvn -Dmaven.test.skip=true package skips the surefire test mojo.
to ignore test failures and keep maven from stopping you can add this to the section of the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
The solution is:
mvn -fn clean install
execute mvn --help for advanced options
Here's the excerpt for -fn
-fn,--fail-never NEVER fail the build, regardless
of project result
<properties>
<maven.test.skip>true</maven.test.skip>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
</properties>
http://jira.codehaus.org/browse/SUREFIRE-319
Or from command line
http://maven.apache.org/maven-1.x/plugins/test/properties.html
maven.test.error.ignore Yes Set
this to true to ignore errors during
testing. Its use is NOT RECOMMENDED,
but quite convenient on occasion
Use -DskipTests=true instead of -Dmaven.test.skip=true in order to skip tests but compile them.
Using -Dmaven.test.failure.ignore=true will also work but is not very nice.
Use the maven option -Dmaven.test.skip=true
E.g.
mvn package -Dmaven.test.skip=true

How do you clear Apache Maven's cache?

Recently, Apache Maven seems to be having caching issues. Performing clean installs on our projects using Windows Vista or Windows 7 sometimes produce artifacts with the same data as a previous build even though the newer artifact's files should have been updated.
Is there any way to clear this cache to force maven to always trigger a clean build of the local artifact that should be built?
In particular, we're having issues building a webapp with the war plugin. Maven version is 3.0.3. War plugin version is 2.1.1.
Delete the artifacts (or the full local repo) from c:\Users\<username>\.m2\repository by hand.
To clean the local cache try using the dependency plug-in.
mvn dependency:purge-local-repository: This is an attempt to delete the local repository files but it always goes and fills up the local repository after things have been removed.
mvn dependency:purge-local-repository -DreResolve=false: This avoids the re-resolving of the dependencies but seems to still go to the network at times.
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false: This was added by Paweł Prażak and seems to work well. I'd use the third if you want the local repo emptied, and the first if you just want to throw out the local repo and get the dependencies again.
I would do the following:
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false --fail-at-end
The flags tell maven not to try to resolve dependencies or hit the network. Delete what you see locally.
And for good measure, ignore errors (--fail-at-end) till the very end. This is sometimes useful for projects that have a somewhat messed up set of dependencies or rely on a somewhat messed up internal repository (it happens.)
Have you checked/changed the updatePolicy settings for your repositories in your settings.xml.
This element specifies how often updates should attempt to occur.
Maven will compare the local POM's timestamp (stored in a repository's
maven-metadata file) to the remote. The choices are: always, daily
(default), interval:X (where X is an integer in minutes) or never.
Try to set it to always.
Use mvn dependency:purge-local-repository -DactTransitively=false -Dskip=true if you have maven plugins as one of the modules. Otherwise Maven will try to recompile them, thus downloading the dependencies again.
This works on the Spring Tool Suite v 3.1.0.RELEASE, but I'm guessing it's also available on Eclipse as well.
After deleting the artifacts by hand (as stated by palacsint above) in the /username/.m2 directory, re-index the files by doing the following:
Go to:
Windows->Preferences->Maven->User Settings menu.
Click the Reindex button next to the Local Repository text box. Click "Apply" then "OK" and you're done.
As some answers have pointed out, sometimes you really want to delete the local repository entirely, for example, there might be some artifacts that can't be purged as they are not anymore referenced by the pom.
If you want to have this deletion embedded in a maven phase, as for example clean you can use the maven-clean-plugin and access the repository through the settings, for example:
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo>Base clean is attached to deleting local maven cache</echo>
<echo>${settings.localRepository}</echo>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<inherited>false</inherited>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<filesets>
<fileset>
<directory>${settings.localRepository}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
I've had this same problem, and I wrote a one-liner in shell to do it.
rm -rf $(mvn help:evaluate -Dexpression=settings.localRepository\
-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -B \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | grep -vF '[INFO]')/*
I did it as a one-liner because I wanted to have a Jenkins-project to simply run this whenever I needed, so I wouldn't have to log on to stuff, etc.
If you allow yourself a shell-script for it, you can write it cleaner:
#!/usr/bin/env bash
REPOSITORY=$(mvn help:evaluate \
-Dexpression=settings.localRepository \
-Dorg.slf4j.simpleLogger.defaultLogLevel=WARN \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
--batch-mode \
| grep -vF '[INFO]')
rm -rf $REPOSITORY/*
Should work, but I have not tested all of that script. (I've tested the first command, but not the whole script.) This approach has the downside of running a large complicated command first. It is idempotent, so you can test it out for yourself. The deletion is its own command afterwards, and this lets you try it all out and check that it does what you think it does, because you shouldn't trust deletion commands without verification. However, it is smart for one good reason: It's portable. It respects your settings.xml file. If you're running this command, and tell maven to use a specific xml file (the -s or --settings argument), this will still work. So you don't have to fiddle with making sure everything is the same everywhere.
It's a bit wieldy, but it's a decent way of doing business, IMO.
So there are some commands which you can use for cleaning
1. mvn clean cache
2. mvn clean install
3. mvn clean install -Pclean-database
also deleting repository folder from .m2 can help.

Resources