Compile maven sub-project with gradle - maven

i have a gradle project that need the jars generated by a subproject that uses maven.
Can I automatize the compilation of the maven project through gradle and declare it as a dependency ?

A common solution is to call out to Maven via an Exec task, then collect the Jar(s) from the file system.

Related

How to reference local Gradle project from Maven build as dependency?

I have several Gradle library projects and main Ant spring web-app project (historically). I'd like to replace Ant with Maven for main project while keeping existing Gradle projects nature.
Is it possible to refer local Gradle projects from pom.xml as local dependencies of Maven project?
Search readily gives me the opposite - "how to refer maven projects from gradle builds", but not my case.
Gradle always builds locally build/libs (or distributions); the only easy way to share the build dependencies between completely different projects is 'as maven repository dependencies'
in your case the options are
Work Local Builds only
add the maven plugin to the gradle builds - do local install
and refer them in the maven build locally.
Build Anywhere
Your Gradle builds publish artefacts to your local nexus
and you refer them properly in your dependencies
--
Gradle by default does not have 'maven install'; it can be added using the maven plugin see - https://docs.gradle.org/current/userguide/maven_plugin.html#header.

How to run Maven Javadoc in a project with pom packaging?

I have a project that packages the delivery of a software using the assembly plugin. The packaging of the project is pom.
To make a nicer documentation i am using the dependency plugin to download the sources of the different projects and then using the javadoc plugin to generate a new documentation that merges the javadoc for the different projects into one.
The issue I am having is that maven javadoc will not run if the packaging is pom.
It complains with the message: Not executing Javadoc as the project is not a Java classpath-capable package
However, if I put packaging jar it works. Unfortunately then an empty unwanted jar file is generated.
Is there a way to get the maven javadoc to run with packaging pom?
Cheers,
Javi
The workaround I have found was to set the packaging in the pom to jar and prevent maven jar plugin to generate the jar.

How do I create the junit5 maven POM files from gradle?

I'm attempting to build (a fork of) jUnit5.
./gradlew build
produces the JARs, but I also need the pom.xml files that go with the JARs, so I can use the artifacts using Maven. Changes are there is a gradle task configured that does this already in the existing jUnit repo, but which?
Figured it out. Gradle is non-obvious to me ... it is the "maven" plugin.
Invoke:
./gradlew install
which will:
Generate POMs into directory .../build/poms with name pom-default.xml
Copy those (while renaming) and the JARs into the local Maven repository at ~/.m2.

How to get which dependency and dependency version will pack into war file in gradle build file?

I want to print all dependency groupId, artifactId and version which will pack into war package in multiple module gradle project.
What can I do?
You can run the dependencies task on the project that defines the war. And in the linked documentation page has a number of other methods for investigating dependencies of a Gradle project.

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.

Resources