py *_*y y 3 java plugins war gradle
我有一个相当简单的要求。我有以下项目布局:
project/build.gradle
--src/main/java
--src/main/res
Run Code Online (Sandbox Code Playgroud)
我想做的是为所有的java文件创建一个jar project/src/main/java
在war中包含这个jar文件,然后从war文件中排除WEB-INF/classes
build.gradle样子如下:apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jetty'
apply plugin: 'war'
dependencies {
..
compile 'com.fasterxml.jackson.core:jackson-core:2.3.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.0'
..
}
jar {
archiveName = 'hello.jar'
}
war {
dependsOn jar
archiveName = 'hello.war'
classpath fileTree(dir:'build/libs/',include:'*.jar')
classpath configurations.compile
webInf {
from ('src/main/res') {
include '**/*.*'
into 'resources/'
}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了各种排除方法,WEB-INF/classes包括以下片段:
使用rootSpec.exclude:
war {
dependsOn jar
archiveName = 'hello.war'
classpath fileTree(dir:'build/libs/',include:'*.jar')
classpath configurations.compile
rootSpec.exclude ('WEB-INF/classes')
...
}
Run Code Online (Sandbox Code Playgroud)
使用类路径:
war {
dependsOn jar
archiveName = 'hello.war'
classpath fileTree(dir:'build/libs/',include:'*.jar')
classpath configurations.compile
classpath fileTree(dir:'build/classes/', exclude:'*.class')
...
}
Run Code Online (Sandbox Code Playgroud)
使用自('war'):
war {
dependsOn jar
archiveName = 'hello.war'
classpath fileTree(dir:'build/libs/',include:'*.jar')
classpath configurations.compile
from ('war') {
exclude('WEB-INF/classes')
}
}
Run Code Online (Sandbox Code Playgroud)
做一个直接的“排除”:
war {
dependsOn jar
archiveName = 'hello.war'
classpath fileTree(dir:'build/libs/',include:'*.jar')
classpath configurations.compile
exclude('WEB-INF/classes')
...
}
Run Code Online (Sandbox Code Playgroud)
这是我在网上找到的所有建议 - 但它们似乎都不起作用。任何想法我做错了什么。
以下是我找到的一些文章和代码的链接: Gradle: War Task has Conflicting Includes/Excludes
https://github.com/veny/smevente/blob/master/build.gradle
该gradle这个版本是2.12。
以下是对我有用的内容,但您仍会在 war 包中看到一个(无害的)空包:
war {
rootSpec.exclude('**/com/xxxxx/web/client/')
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7492 次 |
| 最近记录: |