I'm running the jdepend maven plugin on my project and whether I run "mvn site:site" or "mvn jdepend:generate" the report that gets generated says "There are no package used." There are no errors in the maven output. Other plugins (cobertura, findbugs, etc.) run fine. My pom is configured like this:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
</plugin>
Any ideas?
Did you try running "mvn -U -cpu site:site" to update all the maven dependencies?
Maybe this question is better asked in the Maven forum :)
Related
I am new to Liquibase. I have already included maven plugins and liquibase to my pom.xml however when i update liquibase using mvn liquibase:update I get this error:
No plugin found for prefix 'liquibase' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
How can I fix this error so that when I type mvn liquibase:update it will run properly
Here are some of the dependencies that are in my pom.xml related to liquibase
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
</build>
I don't think the problem is with liquibase plugin itself. It's more about maven prefixes.
Try executing: mvn org.liquibase:liquibase-maven-plugin:update
Also, check out this question.
Make sure you are in the right path when you are executing mvn liquibase:update command. And also try to run the command in a separate terminal like command prompt. In my case I'm using the terminal in IntelliJ IDEA when I had the problem but when I tried it in different terminal, it worked flawlessly.
In my case problem was in path. I was trying to start command c:\mvn.cmd liquibase:status from wrong folder.
Running from c:\projects\My_current_project\mvn liquibase:status works like a charm. c:\projects\My_current_project\ is folder, where pom.xml is.
In my case the issue was my pom is configured in such a way that the liquibase plugin is only defined under certain profiles which need to be passed in before the mvn liquibase:<your command here> gets run.
for example, if the pom.xml has a local profile and your liquibase plugin is ONLY defined under that profile, you should run something like mvn -P local liquibase:update in order for maven to pick up liquibase (since it's only defined in that profile)
I have a project with finalised version in pom files , lets say 12.3.45 .
I have built the code for this version some time ago already, all the built jars are in the local maven repo.
Then at some point I have run mvn clean, so all the target folders are being removed.
And now I want to execute some code, as quickly as possible, using mvn exec:java. Preferably without building anything, because why not? all the jars at some point were already built, and I know there were no code changes after that. How can I force maven to execute the code as fast as possible , not recompile anything, and just reuse the jars from the local repo?
Thanks.
If your artifacts are in a local or remote repository you can use them as dependencies.
You can use exec-maven-plugin's options includeProjectDependencies or includePluginDependencies to use them in java execution
https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#includePluginDependencies. includeProjectDependencies option is enabled (true) by default.
You can execute exec-maven-plugin without building anything with mvn exec:java command
Instructions:
To run exec-maven-plugin you would need a main class to run. I assume you have one in your project. If you don't - you need to make a separate project with a main class.
Create a blank maven project.
In the project add exec-maven-plugin configuration. Set the mainClass
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>pack.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Include you artifacts as dependencies to the project
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>myartifact</artifactId>
<version>12.3.45</version>
</dependency>
</dependencies>
Run mvn exec:java to execute com.my.package.MyMainClass main class from my.group.myartifact artifact
Edits:
includeProjectDependencies option is enabled (true) by default
A common Maven debugging technique is to use mvn dependency:tree to view the graph of project dependencies.
However, this list shows the project dependencies, not the plugin dependency tree for each plugin. Is there some way to do this from a project?
The output via mvn -X will printout the information indirectly. Currently there is no other option to get the dependencies of a Maven-Plugin.
Update
You can use the following command to get a list of plugin dependencies (resolve-plugin goal from dependencies plugin):
mvn org.apache.maven.plugins:maven-dependency-plugin:2.10:resolve-plugins
The shorter version is (and it is a bad habit to specify plugin versions)
mvn dependency:resolve-plugins
If you are using any IDE like IDEA IntelliJ or Eclipse:
You can add this below plugin in your pom.xml
Once done, On the Maven window (on the right of IDE), you will find a new plugin called as
Dependencies
Expand that and you will see the dependency:tree goal, double click
on it and run it, you should see the full dependency tree
Plugin to be added in POM:
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
I'm using maven in my project and I need to run the build in a non-internet-access machine.
When I test my project build everything is working, but when I run the build in a future moment, the maven try to update the mvn-plugins and this sht* is broking my build.
My config file: settings.xml from mvn.
<profile>
<id>blaProfile</id>
<repositories>
<repository>
<id>blaRepo</id>
<url>file://${bla.3rdParty.home}/maven/.m2/repository</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>blaRepo</id>
<url>file://${bla.3rdParty.home}/maven/.m2/repository</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
</profile>
<activeProfiles>
<activeProfile>blaProfile</activeProfile>
</activeProfiles>
And I ran my maven is with the params:
mvn -npu -bla.3rdParty.home="$(THE_CORRECT_PATH)" package
I saw that maven try to update some mvn-plugins for some time, but the option:
-npu,--no-plugin-updates Suppress upToDate check for any relevant
Should work for this updates.
Well waiting some help on that!
Thanks in advance!
UPDATE(1):
What I'm looking at, is that I could use the setting:
<usePluginRegistry>true</usePluginRegistry>
Inside my settings.xml and with this, I'll have a plugin-registry.xml inside ${user.home}/.m2 that I can config and force the maven plugins versions.
But it's not working! :(
Before you go offline run the following:
mvn dependency:go-offline
That will download all your dependencies and plugins that you need to build your project into ~/.m2/repository.
Once you've run that you can now build your project offline using the '-o' flag:
mvn install -o
In order to cache plugins into the .m2/repository folder you would need to specify all plugins explicitly with the mvn <maven-plugin-name>:help
You would also need to specify explicit version for each plugin in the <plugins> or <pluginsManagement> section of your pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
</plugin>
This is needed to make sure that mvn install -o uses the same plugin version.
Ofcourse you would also need to run mvn dependency:go-offline to take care of your compile and test dependencies.
mvn assembly:help compiler:help enforcer:help exec:help failsafe:help install:help jar:help resources:help surefire:help
mvn dependency:go-offline
mvn compile --offline
Maven Go-offline + Isolated Docker Multi-stage Image Builds
My answer is for both a local build or a Dockerized environment, which is isolated on the nature of how docker images are built. This uses Maven 3.6.3-jdk-8.
With this answer, you know exactly how much time your CI spends on downloading, compiling, testing, packaging...
Finally, also answering to the old question on Jira for the go-offline https://issues.apache.org/jira/browse/MDEP-82?focusedCommentId=16997793&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16997793
Update pom.xml dependencies
maven-dependency-plugin
surefire-junit-platform
Call go-offline resolving dependencies
Call any mvn command with the switch --off-line
Set latest versions of the plugins
## -23,6 +23,9 ##
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<common-io.version>2.6</common-io.version>
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
+ <!-- https://issues.apache.org/jira/browse/MDEP-82 -->
+ <maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
+ <surefire-junit-platform.version>2.22.2</surefire-junit-platform.version>
<maven-release-plugin.version>2.5.3</maven-release-plugin.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-surefire-report-plugin.version>2.22.2</maven-surefire-report-plugin.version>
...
...
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>${maven-dependency-plugin.version}</version>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
## -135,6 +143,11 ##
<target>${java.version}</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit-platform</artifactId>
+ <version>${surefire-junit-platform.version}</version>
+ </plugin>
Create the Go-offline cache
This will ensure all the dependencies are downloaded
More than 3m to download all dependencies
FROM maven:3.6.3-jdk-8 AS dependencies-downloaded
...
...
COPY pom.xml /usr/src/app/pom.xml
COPY settings.xml /usr/src/app/settings.xml
WORKDIR /usr/src/app
RUN mvn -f pom.xml -s settings.xml dependency:resolve-plugins dependency:go-offline
Call compile with --offline
We can reuse the same image for compilation
Only takes 7s because nothing is downloaded
FROM dependencies-downloaded AS compile
COPY app /usr/src/app
WORKDIR /usr/src/app
RUN mvn -f pom.xml -s settings.xml compile --offline
Call tests with --offline
We can reuse the same image for tests
Taking 18s to run the test cases, without any download whatsoever
FROM compile AS tests
WORKDIR /usr/src/app
RUN mvn -f pom.xml -s settings.xml test --offline
Call package with --offline
We can reuse the same image for the final jar
Skipping even the tests ran in the previous docker image
Taking way less than before
FROM tests AS package
WORKDIR /usr/src/app
RUN mvn -f pom.xml -s settings.xml package -Dmaven.test.skip=true --offline
The final runtime image is a Docker image from the package.
FROM JRE
COPY --from package /usr/src/app/target /bin
...
...
It should suffice to run a mvn clean install on your code. The next time, when you run it in an offline mode you can use the following options:
mvn -Dmaven.repo.local=..\repository –o clean install
-o tells Maven not to try to update its dependencies over the network and with -Dmaven.repo.local you provide the path of the repository which contains all the required dependencies.
Alternatively, you can add the path of the repository in your settings.xml in the localRepository tag and add an <offline>true</offline>.
You can configure the same in your Maven Eclipse configurations.
After some debugging I found that maven-dependency-plugin (version 3.1.1 at the time of writing) is unable to resolve plugin's dependencies when specified like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<dependencies>
<dependency> <--- this is not going to be resolved by dependency:go-offline command !!!
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit4</artifactId>
<version>3.0.0-M3</version>
</dependency>
</dependencies>
</plugin>
After that I found go-offline-maven-plugin which just works! Pls see https://github.com/qaware/go-offline-maven-plugin for more info.
<plugin>
<groupId>de.qaware.maven</groupId>
<artifactId>go-offline-maven-plugin</artifactId>
<version>x.y.z</version>
</plugin>
Current version could be found here https://mvnrepository.com/artifact/de.qaware.maven/go-offline-maven-plugin and Maven issue here https://issues.apache.org/jira/browse/MDEP-82
I think this happens because Maven hasn't got the metadata available locally to determine if its plugin versions are correct. If you specify exact versions for your plugins (which is a good idea for reproducability anyway), it doesn't need to do the check, so will not try to connect to the remote repositories.
By specify exact versions, I mean that in your project's POM you should add the version to the plugin declaration. For example:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<!-- set the version explicitly-->
<version>2.0</version>
</plugin>
</plugins>
Note you can also force Maven to use internal repositories instead of Central by setting up repository mirrors. See this answer for more details on using repository managers and mirrors.
In the config you included, you're setting your remote repository to point to your local repository, this is not a good idea. To run offline you should either pass -o at the command line or add this to your settings.xml:
<offline>true</offline>
I created a web project with maven like this:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp
Then I run mvn eclipse:eclipse so that an eclipse project is built. Eclipse recognizes all the features of the project but it doesn't recognize it as a web project.
Therefore, when I create a server inside my eclipse workspace, and go to the dialog where I select what projects to deploy to my server, I am not offered to deploy my newly created project.
Ideas?
You should explicitly mention in your pom.xml that the maven-eclipse-plugin should generate a WTP-project. A simple example, which should be in your pom.xml at the build-part, would be:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<wtpmanifest>true</wtpmanifest>
<wtpapplicationxml>true</wtpapplicationxml>
<wtpversion>2.0</wtpversion>
</configuration>
</plugin>
</plugins>
You can also use mvn eclipse:eclipse -Dwtpversion=2.0 to generate all WTP meta-data for the project without changing the POM.
Of course, you'd have to change the WTP version if you are using an older version of Eclipse.
Just install a development version of m2eclipse and your project will be used as a maven project, no need to do mvn eclipse:eclipse or anything like that. I use it and works.
http://m2eclipse.sonatype.org/
Did you jump from the create command to the eclipse:eclipse command?
Check out this link. You need to edit your POM first, then call "mvn clean package". After you do that, THEN try the "mvn eclipse:eclipse".