Skip to content

Commit

Permalink
Added command line flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Rylern committed May 3, 2024
1 parent 254b45f commit 3836039
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions qupath-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,30 +122,52 @@ jpackage.dependsOn(mergedJavadocJar)


/**
* Retrieve Javadocs of dependencies
* Retrieve Javadocs of dependencies and sub-projects
*/
tasks.register("getJavadocsOfDependencies", Copy) {
def componentIds = configurations
.runtimeClasspath
.incoming
.resolutionResult
.allDependencies
.collect { it.selected.id }

def result = dependencies.createArtifactResolutionQuery()
.forComponents(componentIds)
tasks.register("getJavadocs", Copy) {
group = "documentation"
description = "Retrieve the Javadocs Jar of all dependencies and sub-projects"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn rootProject.subprojects.tasks.collect {it.withType(Jar)}

def subProjectsJavadoc = rootProject.subprojects
.collect {it.layout.buildDirectory.dir("libs").get().getAsFileTree().getFiles().findAll {it.name.contains("javadoc")}}
.findAll {it.size() == 1}
.collect {it.toList().get(0)}
def dependenciesJavadoc = dependencies.createArtifactResolutionQuery()
.forComponents(configurations
.runtimeClasspath
.incoming
.resolutionResult
.allDependencies
.collect { it.selected.id }
)
.withArtifacts(JvmLibrary, SourcesArtifact, JavadocArtifact)
.execute()

def javadocFiles = new TreeSet<File>()
for (component in result.resolvedComponents) {
def artifacts = component.getArtifacts(JavadocArtifact)
javadocFiles.addAll(artifacts.collect(a -> a.file))
}
from javadocFiles
into layout.buildDirectory.dir("dependencies-javadoc")
.resolvedComponents
.collect {
it.getArtifacts(JavadocArtifact).collect {it.file}
}
.flatten()
def allJavadocs = subProjectsJavadoc + dependenciesJavadoc

from allJavadocs
.findAll {
def docs = findProperty('docs') ?: 'default'

if (docs == "all") {
return true
} else if (docs == "none") {
return false
} else if (docs == "qupath") {
return it.name.startsWith("qupath")
} else {
return it.name.startsWith("qupath") || it.name.startsWith("jts") || it.name.startsWith("ij")
}
}
into layout.buildDirectory.dir("javadocs")
}
tasks.installDist.dependsOn("getJavadocsOfDependencies")
tasks.installDist.dependsOn("getJavadocs")

/**
* Create license report
Expand Down Expand Up @@ -204,9 +226,9 @@ distributions {
into('lib/docs') {
from mergedJavadocJar.archiveFile
}
// Copy javadoc of dependencies
// Copy javadocs
into('lib/docs') {
from layout.buildDirectory.dir("dependencies-javadoc")
from layout.buildDirectory.dir("javadocs")
}
}
}
Expand Down

0 comments on commit 3836039

Please sign in to comment.