Maven dependency in a Gradle project

I'm developing a project with gradle. My build file is almost empty so far:

apply plugin: 'java'
apply plugin: 'eclipse'

version = '0.1'

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

My project depends on a Maven project. Precisely this project: http://git.eclipse.org/c/bpmn2/tree/org.eclipse.bpmn2

I've cloned this project into my workspace, but I don't know the best way to declare the dependency in my build.gradle file. This is what I've done so far:

dependencies {
    compile files ("C:/path/to/org.eclipse.bpmn2-0.7.0-SNAPSHOT.jar")
}

But this way I have to manually build the maven project. Does somebody know a better way of doing this dependency management?

I'm using Eclipse Gradle Integration and I've noticed an interesting eclipse project property:

Gradle - Dependency Management
[x] Remap Jars to maven projects (requires Gradle 1.1 and m2e)

This seems to do what I need. But I don't know how to use this feature...

Thanks in advance.


If the Maven project is not available in any Maven repo, Gradle can't find it anywhere, so you'll have to build it. I would at least mvn install it, and tell Gradle to look for artifacts in your local Maven repo rather than in a specific directory, using

repositories {
    mavenLocal()
}

The eclipse-integration-gradle plugin replaces the mavenLocal() jar dependency with a Eclipse project dependency. This is the easiest way I've found so far. See: http://forum.springsource.org/showthread.php?139634-How-to-use-quot-remap-Jars-to-maven-projects-quot-feature

链接地址: http://www.djcxy.com/p/57506.html

上一篇: 开始在现有项目中使用Maven而不会丢失GIT历史记录

下一篇: Gradle项目中的Maven依赖项