我确定这很简单,但是找不到任何示例从生成的java doc中删除源代码树。我的源代码树是
src/main/java/...
src/test/java/...
src/samples/java/...
我尝试了两项任务,似乎都没有效果。
javadoc {
exclude "src/test/**"
exclude "src/samples/**"
}
task gendocs(type: Javadoc) {
source = sourceSets.main.allJava
classpath += configurations.compile
exclude "src/test/java/**/*"
}
这是完整的文件(更新以尝试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'
}
答案 0 :(得分:0)
您的脚本出现了许多问题,因此将在单独的答案中解决这些问题
src/test/x
不应该在sourceSets.main
下(它已经在sourceSets.test
下)。将测试源放在主sourceSet中意味着测试类最终会被包装在你的jar中!! java
个文件夹不应位于sourceSets.x.resources
下。 Java文件夹只应包含*.java
个文件。任何资源(例如*.xml
和*.properties
)都应该位于src/x/resources
个文件夹中。在您的资源中放置java
个文件夹意味着您的普通*.java
文件也会在jar中结束!! javadoc
包含特定文件夹,请不要以sourceSets.main.allJava
开头。只需按照@Stanislav exclude
内的FileTree.matching { }
相对于FileTree
根。此时exclude 'src/test/**'
和exclude 'src/samples/**'
无效。 exclude
内的javadoc
也是如此。查看exclude
任务下的test
。这些都是正确的根相对。