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

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.

Related

Where to find the builded artifactories using gradle

I'm coming from the Maven world, and I want to know where to find the local builded packages using gradle.
In maven these packages are published in the m2 repository. Is there something similar in gradle ?
Gradle does not publish any artifacts in Maven-compatible repositories by default. In order to do that you'll need to use maven-publish plugin.
However, build results are actually cached in $GRADLE_USER_HOME directory which is ~/.gradle by default: ~/.gradle/caches, ~.gradle/caches/modules-2/files-2.1.

Why gradle not creating local repository and downloading same dependencies for every project

I'm using Gradle with Java Project in IntelliJ Idea.
I see that Gradle downloading dependencies for first time on opening project.
But there is another project with same dependencies then also it's re-downloading those libs. why?
Why doesn't it maintain Maven like local repository even after configured?
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
How can Gradle maintain local repository and next it should first check local repo and go for download if no matching dependencies found?
With that piece of code you instruct gradle to look at the local maven repository, then at the central maven repository and last in JCenter when looking for dependencies. The first one it finds your dependency it takes it from.
It does not instruct Gradle to put resolved dependencies to the local maven repository though. This is e. g. helpful if you have two projects in two separate builds, one depends on the other and you install the first dependency to the local maven repository with the respective Gradle task and then build the second one, depending on the version you just built and installed.
Gradle has a resolution cache though in ~/.gradle/caches/modules-2/files-2.1/ where it caches all downloaded dependencies and also reuses this from different builds.

Importing a snapshot version of a dependency into Maven repository

I am having trouble importing dependencies for my Grails project into the company Nexus repository. The Grails plugin I would like to use is events-push (https://github.com/smaldini/grails-events-push). The latest released version of the plugin is 1.0.M7. It uses a very old version of Atmosphere library. The GutHub repository contains a more up-to-date version of events-push plugin, 1.0.0.BUILD-SNAPSHOT. I built the Grails plugin from the local clone of the repository and got it to work in my dev environment.
To deploy it on the intranet (in the production environment) I need to import all the plugin dependencies into the company Nexus repository. This is where I run into trouble. The project depends on a SNAPSHOT version of events-push plugin, which in turn depends on SNAPSHOT version of other Grails plugins and Java libraries (according to dependency report).
Nexus supports two types of repositories, Release and Snapshot. I can add artifacts to a Release repository (through the browser UI or in a batch mode using curl), but the artifact must not be a snapshot. I can change the repository to be a Snapshot repository, but then I lose the ability to add artifact to it through the browser or curl command.
How do I make these SNAPSHOT artifacts available to the Grails project through Maven?
Change them to a release version and deploy them to the release repository.

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.

Grails refresh-dependencies doesn't download snapshot dependency from local maven repository

I am using Grails 2.1.1 and Maven 3.0.3.
In my buildConfig.groovy, I have pom true and I generated the pom.xml via grails create-pom. In this pom I have a dependency with <version>1.0-SNAPSHOT</version> which exists only in my local maven repository. I can successfully run mvn clean compile on this pom.
However running grails refresh-dependencies does not download the most recent version of my snapshot dependency from my local maven repository. The only way I can get it to download the latest version is to manually delete it from the ivy cache.
According to the documentation:
All dependencies (jars and plugins) with a version number ending in -SNAPSHOT are implicitly considered to be changing by Grails.
I assume it would recognize my snapshot file as changing and download it when it is modified. Am I missing some other configuration step? I only want to use maven for dependency management, but is this entirely the wrong way to use Maven with Grails?
This is actually the normal behavior of the Aether resolver.
--refresh-dependencies doesn't bypass your local maven cache. To do that, you'll need to set the maven repository that contains your dependency to always download new snapshots. In BuildConfig.groovy's repositories block:
mavenRepo ("http://my.server/repos/my-grails-plugins") {
updatePolicy 'always'
}
Credit to http://asoftwareguy.com/2013/10/25/grails-2-3-maven-dependency-caching-issues/.
Since I haven't got any responses, what seems like the solution to this is to just not use the grails command line, but rather use the maven goals for Grails.
mvn grails:run-app does the trick. All snapshot dependencies are refreshed and I can start up my app and see the local changes reflected. This way I'm ignoring ivy altogether and letting maven take care of everything.
Edit: If you go this route, I suggest following chapter 5 of the User Guide on Maven Integration for setting up your pom.xml, etc. I was able to follow this and get it set up without any surprises.

Resources