Hi,
trying to make my code CC compatible, I stumbled over the following problem / question.
With the “old” API I could do the following:
doFirst {
testPlugins
.resolvedConfiguration
.resolvedArtifacts
.filter { it.extension == "hpi" || it.extension == "jpi" }
.forEach {
pluginsMapping[it.file.name] = JenkinsPlugin(it.name, it.extension)
}
}
The testPlugins configuration has module dependency and also a local subproject one. In the code above this is all abstracted and I can get e.g. name or group of the artifact, see [0].
I tried to use the incoming view on that to use [1] and rewrote it like that:
val artifacts: Provider<Set<ResolvedArtifactResult>> =
testPlugins
.incoming
.artifacts
.resolvedArtifacts
doFirst {
artifacts
.get()
.filter { it.file.extension == "hpi" || it.file.extension == "jpi" }
.forEach {
val pluginName =
when (val compId = it.variant.owner) {
is ModuleComponentIdentifier -> {
compId.moduleIdentifier.name
}
is DefaultProjectComponentIdentifier -> {
compId.projectName
}
else -> {
throw GradleException("$compId unknown!")
}
}
Logging.getLogger("plugin").debug("Build-Mapping: {} with filename: {}", pluginName, it.file.name)
JenkinsHelper.pluginsMapping[it.file.name] = JenkinsPlugin(pluginName, it.file.extension)
The result list does not have anymore in the forEach body a name + group I can use, but I have to make a difference between modules and local projects.
For my example I used the “hack” that I know my projectName is the same like the module name of my subproject, but how would I e.g. access the group in the DefaultProjectComponentIdentifier case, I am looking for something like:
is DefaultProjectComponentIdentifier -> {
compId.moduleInfo.name
}
My best guess is, I miss some API / doc link how I can access those information - anyone can help me with that?