What is the difference between gradle install and gradle publishToMavenLocal? - gradle

In gradle, the install task is introduced by the maven plugin.
The publishToMavenLocal task is introduced by the maven-publish plugin.
The documentation of both tasks says they install/publish the module/artifacts to the local maven cache (.m2 directory).
If I need to publish a local project to my local maven cache, so that another local project can depend on it, which of the two tasks should I use?

As far as I know, these two accomplish the same thing.
That said, I recommend using the maven-publish plugin because:
It's newer and has a nicer publishing DSL, see the Maven Publish Plugin page for more details
It doesn't explicitly depend on the java plugin, which is useful if you ever build non-Java projects
You can always write: task install(dependsOn: 'publishToMavenLocal') if you like the task name install.

Related

can you build a maven project inside of a gradle wrapper

It may be just that I have a general misunderstanding how gradle build works, but it feels to me that I can not build a maven file inside of a gradle build. Since gradle uses the gradle.build file, and maven uses a pom.xml, it does not seem as though I can do this. I have multiple maven projects that I would like to wrap up with a gradle wrapper. I can not find ANYTHING on whether this is even possible.
Both Maven and Gradle are build tools and you should only use one of them for a given project.
If you have existing Maven projects and like the functionality provided by the Gradle wrapper, there is a similar wrapper for Maven (note that this is currently a third-party plugin but they plan to include it in the upcoming release 3.7 of Maven).
Alternatively you could convert your projects entirely to Gradle.

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.

Difference between gradle upload and gradle publish

I am testing pushing my artifacts to a Nexus maven repository. I am using gradle to do so.
What is the difference between gradle upload and gradle publish?
Currently gradle provides two publishing mechanisms. Original - shipped with java plugin - is described here and is based on a task of type Upload. This mechanism is going to be replaced by the - currently incubating - second mechanism that is separated from java plugin and also splitted into maven and ivy. This new mechanism is described here.
Also have a look at "Upgrading your build from Gradle 6.x to the latest": "Removal of the uploadArchives task: The uploadArchives task was used in combination with the legacy Ivy or Maven publishing mechanisms. It has been removed in Gradle 7. You should migrate to the maven-publish or ivy-publish plugin instead."

Building Maven sub-modules in a Gradle project

I have a Gradle build working for a bunch of Java and C sub-modules. I would like to add several sub-modules which are incoming from existing code base and are already setup as Maven builds. Is there a way for Gradle to pickup the Maven sub-modules as part of the parent build?
It seems, there is no native way to run some maven goal within gradle build script. By the way, it is possible to run a maven goal, just providig a custom task of Exec type, which will run a maven build as a command line process. You can read more about this task type here.
Furthermore, it is even possible to provide the maven goal artifacts as dependencies for the gradle project, after you build them from custom gradle task and specify the file-dependency with builtBy property. You can read about it in the official user guide.

how to build playorm JARs

I am new to playorm and gradle. My goal is to get playorm compiled (especially play 2.1 plugin) and deployed to local nexus repository manager.
What gradle tasks should I invoke to do this?
I tried to run gradlew clean assemble - creates workspace*.jar in output/libs so I assume build part was done. How to get these artefacts renamed and uploaded to my nexus?
https://github.com/deanhiller/playorm
You'll want to read this chapter of the user guide. It looks like the only repository configured for playorm is Maven Central, but the user guide tells you how to configure your own repository and interact with it. After following the guide, if you have a more specific question ask again here.
I created local.gradle and included it in build.gradle to create uploadArchives task using standard gradle upload procedure.
build.gradle was modified in upstream version to include local.gradle if exists.

Resources