Cannot get the latest version of maven plugin - maven

I am new to maven, I have write my own maven plugin with the pom file
<groupId>com.xxx.api</groupId>
<artifactId>xxx-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
then, in my IDE (intellij) I used clean install to install my maven plugin
and in the main project, my maven plugin works fine.
However, when I modify my maven plugin by adding parameter to my mojo and "mvn clean install" ,
(the groupId,artifactId,version keep the same) it supposed to be the latest version.
However, in the main project, when I try to use the latest maven plugin, I always get the old version
i.e I cannot configure the parameter that I just add to my maven plugin (because it is not exist!)
I have try to delete the maven plugin in my .m2 repo, before I install the latest version of my maven plugin, it still not work.
Any solution that I can get the latest version of my maven plugin by keeping the same
(groupId, artifactId,version)?
thanks,
Zach

Check how the using project is configured. I guess it has its own lib/classes folder. I would suspect that your project has a copy of the older version of the plugin in its lib folder. If so, that is where it is getting the old version. Clean it out from there, i.e. you need to clean the using project.

Related

Is there a way to force intellij to mvn reimport before I build everytime

I am trying to refer to the versions using ranges in my pom
e.g.
[13.1.0-betatest101,13.1.0-betatest110]
When I upload a new version of jar to the nexus hosted within our company maven seems to pick it up and download it to local repository. But intellij is still referring to old version of the jar. The only way to fix is to mvn reimport but is there a way to force this behavior before every build so I am always working with latest version?

Use a snaphot version of the gradle dependency plugin (... in order to test gradle-3.0Mx)

I stumbled over compatibility issues related to the dependency plugin and gradle-3.0M1. Quickly, people told me this might be fixed in the trunk version of the plugin, but not in the latest release version 0.5.7.
Now I wanted to verify this but didn't find an easy way to use the snapshot version of the plugin. In the end, I
downloaded the plugin source by cloning the git repo
rebuilt the plugin
copied the jar file into a folder
made this folder available as flatDir within my build script
Is there a better way to do this? Is there a public mvn repo for the snapshots?
Publish the plugin to your local maven repo (.m2) using either the older maven plugin or the newer maven-publish plugin.
In the project where you want to use/test the plugin you just build, add mavenLocal() as a repository in the buildscript section of build.gradle.

How to build maven project With existing jar in local maven repository

I have issue with Project Building in Maven. I have updated some code in one of the dependency jars which is available in Maven Repository .I need to build my project with the jar i have modified.How to do that .Kindly Help me.
1. Install mvn project
Make sure to install your changed code into your repository.
Run following maven command for your updated library project.
mvn install
2. Check dependency
Check if the version of your library project match with the dependency entry in your main project pom.
E. g. if you install version "1.1" make sure the dependency entry is also "1.1"

Patch versioning in Maven

We have an application which has a patched version released. Now we want to deploy this patched version with some classifier stating that it is a patch version and not a normal release.
So I was trying to test the plugin locally by installing it in the local maven repository and then building the project.
I used a command similar to this to install in the local repository.
mvn install:install-file -Dfile=path/to/the/warfile -DgroupId=com.test.app -DartifactId=web-app -Dversion=default-version -Dpackaging=war -DlocalRepositoryPath=path/to/local/repo -Dclassifier=patch-version
Once the war file is installed in the local repo, I included a dependency in the pom file like this
<dependency>
<groupId>com.test.app</groupId>
<artifactId>web-app</artifactId>
<version>default-version</version>
<classifier>patch-version</classifier>
<type>war</type>
</dependency>
Now when I build the project using mvn clean package, the patched version war file is not picked up from the local repository. Instead it is downloading the default version i.e default-version from the project repository.
I want my project to use the patched version to build the project. Can someone point me to a correct usage or some other better way to do this.

add external plugin to intellij maven project

I'd like to add a plugin to my maven project in Intellij, but I'm not sure where I should download from and where I should put the jar files. For example, I want to use
<plugin>
<groupId>funambol</groupId>
<artifactId>rhinounit-maven-plugin</artifactId>
...
or
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
...
in my pom.xml, but the text between the tags is red.
The rhineunit-maven-plugin does not seem to be found in any central repository. You will have to download the plugin sources yourself from here and then build them by running mvn install where the pom file is located. This will install the plugin in your local repository and the version will be 1.0.
Regarding the jasmin-maven-plugin it can be found here and as you can see the latest stable version is 1.1.0. That means that you will only have to add the version 1.1.0 to your plugin statement and the plugin will be downloaded when you run mvn install (actually in an earlier maven phase but don't bother about that).
Here seems to be a good article on how to use rhinounit-maven-plugin so you should go ahead and study it.
Regarding the tags being red that is caused by IntelliJ not being able to find the jar files in the local repo, especially if you don't set the version for the plugins. Normally IntelliJ shows a little green growl-like thing in the upper right corner that states "Maven projects need to be imported" when you change your pom files from within IntelliJ. If you select "Import Changes" it will try to download your dependencies. Another way to solve it is to run mvn install on your own project from the command line.

Resources