BJ *_*ruz 6 java eclipse gradle
我有以下目录结构:
dir
|
|---project1
| |
| |--build.gradle
| |--src/main/java/com/bpd/app
| |
| |--SomeClass.java
|
|---project2
|
|--build.gradle
|--src/main/java/com/bpd/app
|
|--AnotherClass.java
|--MyClass.java
Run Code Online (Sandbox Code Playgroud)
两者都是单独的Java项目,但SomeClass由于无法找到而无法编译MyClass.
我可以添加project2到project1使用Eclipse 的构建路径(然后SomeClass将编译),但我想知道如何使用Gradle来完成它.可能吗?如何让Gradle添加project2到构建路径project1?
这是build.gradle其中一个项目的文件.只有库依赖项不同.
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
repositories {
mavenCentral()
}
dependencies {
compile "javax.ws.rs:jsr311-api:1.1.1"
compile 'com.sun.jersey:jersey-server:1.13'
compile 'com.sun.jersey:jersey-core:1.13'
compile 'com.sun.jersey:jersey-servlet:1.13'
compile 'com.sun.jersey:jersey-json:1.13'
compile 'javax.ejb:ejb-api:3.0'
compile 'org.eclipse.persistence:javax.persistence:2.0.0'
compile 'org.eclipse.persistence:org.eclipse.persistence.jpa:2.6.2'
compile 'org.xerial:sqlite-jdbc:3.8.11.2'
testCompile 'junit:junit:4.12'
testCompile 'org.assertj:assertj-core:3.2.0'
}
sourceSets.test.resources {
srcDirs = ["src/test/java", "src/test/resources"]
exclude "**/package-info.java"
}
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
checkstyle {
toolVersion = "6.13"
}
Run Code Online (Sandbox Code Playgroud)
Ari*_*Roy 12
它很简单.
步骤1
只需将这些行添加到settings.gradle文件即可
include ':library'
project(':library').projectDir = new File("../MyLibrary/library")
Run Code Online (Sandbox Code Playgroud)
第一行只包含库,第二行指向项目目录.所以一定要正确地做到这一点.".."只是简单地导航目录.
第2步
只需将此行添加到应用程序的build.gradle即可.
compile project(':library')
Run Code Online (Sandbox Code Playgroud)
该行用您的应用程序编译项目.
| 归档时间: |
|
| 查看次数: |
4250 次 |
| 最近记录: |