pkruk
pkruk

Reputation: 859

gradle with maven submodule

There is any way to build gradle project with maven submodule ? I created a project in gradle but at now I must add module (that module used a maven) I don't have any idea how to used this. There is any good way?

I will be very gratefull for any suggestions.

Upvotes: 4

Views: 2573

Answers (2)

Nova
Nova

Reputation: 2666

Create a build.gradle(.kts) that wraps the Maven project in its root directory:

val build = task<Exec>("build") {
    commandLine("mvn", "package")
}

val default by configurations.creating {
    isCanBeConsumed = true
    isCanBeResolved = false
}

artifacts {
    add(default.name, File("$projectDir/target/<name of the jar>.jar")) {
        builtBy(build)
    }
}

You can then depend on it like this:

implementation(project(":<path to the module>", "default"))

Upvotes: 0

Peter Niederwieser
Peter Niederwieser

Reputation: 123920

Either convert the Maven project to Gradle (gradle init is a good start) and turn the Gradle build into a multi-project build, or publish the Maven build's artifact to the local or a remote Maven repository, and configure the Gradle build to consume it from there (or the other way around).

Upvotes: 2

Related Questions