Short version, I have some projects containing SOAP WSDL definitions and (among other things) a task which generates HTML documentation. And I have another project (a war) into which I want to deploy the generated documentation.
Here the are my build scripts… as much as possible, they’re based on this documentation, page with a little bit mixed in from other sources:
First, the code for the projects which produce the documentation, in the form of a custom plugin. I’ve omitted the implementation of the task itself, but it basically takes a list of WSDL files as input, and produces a file in the output directory for each.
def generateSoapDocs = project.tasks.register('generateSoapDocs', steps.build.soapdocs.tasks.GenerateSOAPDocsTask) {
group = 'build'
description = 'Generate SOAP WS docs'
//Default the input files and output directory; no configuration needed.
inputFiles.convention(fileTree(dir: "$projectDir/src/main/resources/service", include: '*/*.wsdl'))
outputDirectory.convention(project.layout.buildDirectory.dir("ws-docs"))
}
configurations {
soapDocsProducer {
canBeResolved = false
canBeConsumed = true
extendsFrom implementation
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "soap-ws-docs"))
}
}
}
artifacts {
soapDocsProducer (generateSoapDocs) {
builtBy generateSoapDocs
}
}
Second, the consumer side. I’m not actually doing anything with the outputs just yet, just printing them out:
configurations {
soapDocs {
canBeConsumed = false
canBeResolved = true
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "soap-ws-docs"))
}
}
}
dependencies {
soapDocs project(":soap-component1")
soapDocs project(":soap-component2")
}
tasks.register('packageSoapDocs') {
doLast {
//I don't really understand this part... I lifted it from some material on report aggregation.
configurations.soapDocs.incoming.artifactView { lenient(true) }.files.each { println it }
}
}
My issue is that when I run the packageSoapDocs
task against the war project, it correctly prints the paths to the ws-docs
directories for each project included in the soapDocs
configuration — but they don’t exist… the generateSoapDocs
task isn’t run.
I’m guessing there’s something trivial that I’m missing, but I haven’t been able to figure it out on my own… my expectation was that the builtBy generateSoapDocs
instruction on the artifacts block would create some kind of implicit dependency on the task, but that doesn’t seem to be the case.
Simon.