How to use a dependency from nexus and pass a revision - maven

On our Nexus server we have a library with version 1.0 and 2.0. I build my main Project with Gradle.
Actually I have a dependency entry in my gradle file to the library from nexus that use lib version 1.0. Everything is fine.
But now I need a Version 2.0 of our library. The Problem is that the POM File of Lib 2.0 on nexus, does not have a standard version Tag anymore with 2.0 in it. like
<groupId>...</groupId>
<articaftId>...</articaftId>
<version>2.0</version>
Instead their is this line
...
<version>${revision}</version>
...
When update the dependency in my Gradle file to 2.0 and try to build my Gradle project with
gradle clean assemble
The build fails with this Message
> Could not resolve com.company.print.lib:print-lib:2.0
Required by:
project :com.company.printservice
> Could not com.company.print.lib:print-lib:2.0
> inconsistent module metadata found. Descriptor: com.company.print.lib:print-lib:0.0.0-SNAPSHOT Errors: bad version: expected='2.0' found='0.0.0-SNAPSHOT'
How I can solve this? Do I need to pass the Revision ob gradle build?

Related

Gradle cannot find Maven parent dependency with version RELEASE

I've got a "project B" with a pom.xml like this:
<parent>
<groupId>org.company</groupId>
<artifactId>projectA</artifactId>
<version>RELEASE</version>
</parent>
<artifactId>projectB</artifactId>
<version>0.0.1</version>
where "project B" has "project A" as parent project pom.
I am trying to create a new "project C" using gradle now and if I want to use "project B" as a dependency, I specify build.gradle like this :
repositories {
maven {
url "http://mycompany:8081/artifactory/repository"
}
}
dependencies {
compile group: 'org.company', name: 'projectB', version: '0.0.1'
}
But I get the following error:
Could not resolve org.company:projectB:0.0.1.
Could not parse POM http://company:8081/artifactory/repository/org/company/projectB/0.0.1/projectB-0.0.1.pom
Could not find org.company:projectA:RELEASE.
Appart from setting my projectA version number to an specific one, is there a way to make this build work with gradle?
Is there a way gradle could find the correct version like maven is doing right now? My other maven projects have no problem finding the correct version.
I do not want to get the latests version of project A, maybe downloading the full project B jar would be enough.
P.D I am using gradle version 4.5 and maven version 3.5.2 on my local computer
I would do the following:
Download the jar and pom of projectB from your artifactory.
Change the pom by replacing "RELEASE" by a concrete version and the version tag of projectB by something new (like replacing version 1.2.3 by 1.2.3-manipulated).
Upload the jar and the new pom to your artifactory.
Reference version 1.2.3-manipulated from Gradle.
AFAIK you do not need to change the original jar or its content, it is enough to change and redeploy the pom file (with a different version that indicates your manipulation).

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"

Not able to import Quartz Monitor plugin in Grails 2.4.3

I have installed quartz plugin for my grails project and have created Job.
BuildConfig.groovy
plugin {
compile ":quartz:1.0.2"
}
now i want to have the following plugin to monitor the jobs i have created.
https://grails.org/plugin/quartz-monitor
For installing this plugin it says
Add a dependency in BuildConfig.groovy:
compile ':quartz-monitor:<plugin version>'
I have added
compile ':quartz-monitor:1.1'
But it is giving Error as:
There was an error loading the BuildConfig: Bad artifact coordinates :quartz-monitor:1.1, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>
after Digging deep i come to know the plugin repo of grails
http://repo.grails.org/grails/plugins/org/grails/plugins/quartz-monitor/
where it has a pom file for this plugin as quartz-monitor-1.1.pom
<modelVersion>4.0.0</modelVersion>
<groupId>org.grails.plugins</groupId>
<artifactId>quartz-monitor</artifactId>
<packaging>zip</packaging>
<version>1.1</version>
......
So, i made changes as adding the groupId from here to my BuildConfig.groovy
now dependencies look like
compile 'org.grails.plugins:quartz-monitor:1.1'
But now i am getting error as
Resolve error obtaining dependencies: Could not find artifact org.grails.plugins:quartz-monitor:jar:1.1 in grailsCentral (http://repo.grails.org/grails/plugins)
how can i install this plugin.
You need to install the latest version:
compile ":quartz-monitor:1.0"
The version 1.1 of quartz-monitor does not exist today (2/Nov/2015). If you open the Grails Plugin Manager, you will see the plugin in the list, if you expand it, you will see all the versions sorted by last to first, and the last is 1.0

Cannot get the latest version of maven plugin

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.

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.

Resources