[英]how do i exclude a source tree from a gradle javadoc task
I'm sure this is trivial, but can't find any examples out there to remove a source tree from the generated java doc. 我敢肯定这是微不足道的,但是找不到任何示例可以从生成的Java文档中删除源代码树。 My source tree is
我的源代码树是
src/main/java/...
src/test/java/...
src/samples/java/...
I have tried two tasks, neither seem to work. 我已经尝试了两项任务,但似乎都没有。
javadoc {
exclude "src/test/**"
exclude "src/samples/**"
}
task gendocs(type: Javadoc) {
source = sourceSets.main.allJava
classpath += configurations.compile
exclude "src/test/java/**/*"
}
Here's the complete file (updated to try Lance Java's suggestion), but no joy. 这是完整的文件(已更新以尝试Lance Java的建议),但并不高兴。
apply plugin: 'java'
apply plugin: 'distribution'
apply plugin: 'maven-publish'
group = 'com.ibm.watson.iot.sound'
version = '0.0.1'
description = 'IoT Sound project build configurations'
sourceSets.all { set ->
def jarTask = task("${set.name}Jar", type: Jar) {
baseName = baseName + "-$set.name"
from set.output
}
artifacts { archives jarTask }
}
sourceSets {
main {
java {
srcDir "src/main/java"
srcDir "src/client/java"
srcDir "src/test/java"
}
resources {
srcDir "src/main/java"
srcDir "src/client/java"
srcDir "src/test/java"
}
}
client {
java {
srcDir "src/client/java"
}
resources {
srcDir "src/client/java"
}
compileClasspath += sourceSets.main.compileClasspath
compileClientJava {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
}
}
// Make so javadoc errors do not cause the gradle command to fail
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
javadoc {
source = sourceSets.main.allJava.matching {
exclude 'src/test/**'
exclude 'src/samples/**'
}
}
test {
testLogging {
events "PASSED", "STARTED", "FAILED", "SKIPPED"
}
exclude 'com/ibm/watson/iot/sound/*/**/*'
include 'com/ibm/watson/iot/sound/*TestSuite*'
}
task release(type: Zip, dependsOn : [javadoc,mainJar, clientJar, publishToMavenLocal]) {
description = 'Builds the release zip for this project'
into ('caa') {
from ('resources') {
include '*.properties'
}
}
into('caa/lib') {
// from ('build/libs/IoT-Sound-0.0.1.jar')
from clientJar.outputs.files
from (configurations.compile)
from jar.outputs.files
from ('src/client/java/logback.xml')
from ('caa.properties')
from ('wpml.properties')
}
into('caa/bin') {
from ('scripts')
fileMode 0755
}
into('caa/samples') {
from ('src/samples/java')
}
into ('caa/docs') {
from ('build/docs')
}
}
println release.archiveName
println relativePath(release.destinationDir)
println relativePath(release.archivePath)
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
api(MavenPublication) {
artifactId 'IoT-Sound-Client'
artifact clientJar
}
}
}
configurations {
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
all*.exclude group: 'com.github.fommil.netlib', module: 'all'
}
repositories {
maven { url "https://repo.eclipse.org/content/repositories/paho-releases/" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "http://repo.maven.apache.org/maven2" }
}
dependencies {
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
compile group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.2'
compile group: 'org.mongodb', name: 'mongo-java-driver', version:'3.2.2'
compile group: 'org.apache.commons', name: 'commons-csv', version:'1.2'
compile 'com.google.code.gson:gson:2.3.1'
compile group: 'log4j', name: 'log4j', version: '1.2.17' // need by SII
compile fileTree(dir: 'lib', include: '*.jar')
compile group: 'org.apache.commons', name: 'commons-math', version:'2.1'
compile group: 'org.apache.commons', name: 'commons-math3', version:'3.4.1'
compile group: 'gov.sandia.foundry', name: 'cognitive-foundry', version:'3.4.3'
compile group: 'tw.edu.ntu.csie', name: 'libsvm', version: '3.17'
compile group: 'junit', name: 'junit', version:'4.12'
compile group: 'org.deeplearning4j', name: 'deeplearning4j-core', version:'0.5.0'
compile group: 'org.nd4j', name: 'nd4j-native-platform', version:'0.5.0'
}
Many things wrong with your script so will address them in a separate answer 您的脚本有很多问题,因此将在单独的答案中解决
src/test/x
should NOT be under sourceSets.main
(it's already under sourceSets.test
). src/test/x
不应在sourceSets.main
下(它已经在sourceSets.test
下)。 Putting test sources in the main sourceSet will mean that test classes end up being packed inside your jar!! java
folders should NOT be under sourceSets.x.resources
. java
文件夹不应位于sourceSets.x.resources
下。 Java folders should contain *.java
files only. *.java
文件。 Any resources (eg *.xml
and *.properties
) should live in src/x/resources
folders. *.xml
和*.properties
)都应位于src/x/resources
文件夹中。 Putting java
folders in your resources will mean your plain *.java
files will also end up in the jar!! java
文件夹放入您的资源中将意味着您的纯*.java
文件也将最终出现在jar中! javadoc
then don't start with sourceSets.main.allJava
. javadoc
包含特定文件夹,则不要以sourceSets.main.allJava
。 Just add the specific folders you need as suggested by @Stanislav exclude
inside FileTree.matching { }
is relative to the FileTree
root. FileTree.matching { }
内部的exclude
是相对于FileTree
根目录的。 exclude 'src/test/**'
and exclude 'src/samples/**'
aren't valid at this point. exclude 'src/test/**'
和exclude 'src/samples/**'
目前无效。 Same goes for exclude
inside javadoc
. javadoc
exclude
。 Take a look at the exclude
under your test
task. test
任务下的exclude
项。 These are correctly root relative.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.