0

我有一个多项目项目,其中有一个ace2依赖的核心项目;它有依赖关系。即使在使用配置时,我似乎也无法让传递依赖项不会出现在其他项目dataentry2、War 的目录中(是的,我希望包含等依赖项)。不仅如此,标记为/的依赖项也最终出现在那里。所以看来我在这里遗漏了一些重要的东西。web-inf\libprovidedcompiletestCompiletestRuntime

主项目:

allprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    repositories {
        mavenCentral()
    }
}

project(':ace2') {
    configurations {
        provided
    }
    sourceSets {
        main.compileClasspath += configurations.provided
        test.compileClasspath += configurations.provided
        test.runtimeClasspath += configurations.provided
    }

    eclipse {
        classpath {
            //Add the provided configuration items to the Eclipse classpath
            plusConfigurations += [ configurations.provided ]
            //But don't export them
            noExportConfigurations += [ configurations.provided ]
        }
    }
    dependencies {
        compile('org.apache.poi:poi:3.11')
        compile('org.apache.poi:poi-ooxml:3.11')
        ....
        provided "org.apache.tomcat:tomcat-catalina:8.0.22"
        ....
        testCompile('junit:junit:4.12') 
    }
}

project(':dataentry2') {
    apply plugin: 'war'
    dependencies {
        compile project(':ace2')
    } 
}

我还尝试ace2了 ace2 自己的项目中的所有内容build.gradle

如果我能解决“应该尊重 noExportConfigurations”的问题,那么我可以将testCompile,添加testRuntimenoExportConfigurations.

任何想法为什么noExportConfigurations(或不管它是什么)不适合我?

我认为项目noExportConfigurations内部的位置与:ace2另一个项目中的 eclipse 的范围不同。我试图将它移到主项目的顶层,build.gradle但我不知道语法。以下内容不起作用:

noExportConfigurations += [ project(':ace2').configurations.provided ]
  • 操作系统:Windows 8
  • 爪哇:1.8
  • Gradle(命令行):2.4
  • 日食:STS 3.6.4(日食 4.4.2)
  • Eclipse Gradle:Gradle IDE 3.6.4.201503050952-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group Pivotal Software, Inc.

感谢安德烈亚斯的评论。我在https://github.com/oehm-smith/gradleMultiprojectProvided创建了一个对我不起作用的简单示例。

根据您的评论,我做了一个 Eclipse > 右键单击​​项目区域 > 导出 > 战争,选择“apir”网络项目和一些目标文件。这个 .war 包含 tomcat 和 junit jars。

你能试试吗 - 有一个https://github.com/oehm-smith/gradleMultiprojectProvided/blob/master/README.md

Gradle Multiproject 具有提供的范围/配置。从 CL 运行 war 会创建一个没有标有“提供”的 jar 的 .war。但是运行 Eclipse > 在 Tomcat 上运行,提供的和测试的 jar 会转到 webinf/lib。

1. cd master
2. gradle war
3. jar tvf ../apir/build/libs/apir.war | grep jar
4. Observe no 'tomcat' jars are in the war

现在在 Eclipse 中执行

1. In Eclipse with Gradle plugin ... 
right-click > import > gradle and select the master project > build > select > ok
2. Choose 'apir' project > right-click > run on server > piviol tc Server is fine to use (or Tomcat)
3. Choose 'pivotal tc Server ' > Browse Deployment Location
4. Observe there ARE 'tomcat' jars in the wtpwebapps/apir/WEB-INF/lib directory
4

0 回答 0