Duplicate entries in plugin.zip
jonnyzzz opened this issue · 6 comments
I'm building a plugin that is compatible with a set of TeamCity versions. It turned out, the gson
library was included in the version I was building against. To workaround it I specified the same dependency for agent
and compile
configurations. As the result, I noticed a duplicated entry in the generated .zip
file of agent plugin.
In the sources in TeamCityAgentPlugin.groovy
I spot the following:
into("lib") {
project.plugins.withType(JavaPlugin) {
def jar = project.tasks[JavaPlugin.JAR_TASK_NAME]
from(jar)
from(project.configurations.runtime - project.configurations.provided)
}
from(project.configurations.agent)
}
It looks like those several from
declarations does not check for duplicates (at least with Gradle 4.7)
Similar code is for the server-side plugin.
My usage example and a workaround are here https://github.com/jonnyzzz/TeamCity.Node/
I was able to observe this problem, not with the gson
library but with the httpclient
library.
An alternative workaround for the problem is to specify a duplicatesStratey
for the agentPlugin
task when adding a dependency to the compile
and agent
configurations.
tasks.withType<Zip> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
A longer term fix is to update the gradle-teamcity-plugin
to use the compileOnly
configuration for TeamCity API dependencies, that would allow the following line, that is removing your explicit dependency, to be removed from(project.configurations.runtime - project.configurations.provided)
.
One more problem, I found out the workaround does not work fully, because of transitive dependencies, which are not being included (probably, excluded by the agentImpl
dependency)
I've published a new version of the plugin, 1.2-beta-1, that uses the compileOnly
configuration for TeamCity API dependencies. I've tried this building your TeamCity.Node plugin without the fix_dependencies workaround and it appears to produce a plugin with the same contents. I also removed the duplcatesStrategy setting, this shouldn't be needed.