Kelvin Chung
08/29/2024, 6:08 PMval configuration = configurations.register("something") {
defaultDependencies {
add(project.dependencies.create("foo:bar:1.0"))
}
}
ant.taskdef("someAnt", "my.ant.AntType", configuration.get())
The error is resulting from a ModuleNotFoundException, saying
Cannot resolve external dependency foo:bar:1.0 because no repositories are defined.
Yet, the plugin is being applied (transitively) to a project for which repositories are defined. Anyone have any insight?Vampire
08/29/2024, 8:25 PMplugins { ... } block is transplanted to a dummy project, configured, and then inspected for the stuff that was added by those plugins to generate accessors for them.
If applying to that dummy project fails, accessor generation fails.
And as that piece of configuration is executed at configuration time with no repositories defined in that dummy project, the resolution of that configuration failed.
The question is, why that taskdef is done at configuration time. It should probably be done at execution time of a specific plugin task so that it also is not done without needing. That would also cause the configuration to not be evaluated prematurely.
Besides that it also makes little sense to create a configuration in user-space with default dependencies when resolving it right away during configuration phase. Then also a detached configuration could have been used. Not that that would change anything regarding missing repositories during accessor generationKelvin Chung
08/29/2024, 8:28 PMAntBuilder.taskdef() without jumping the gun (ie. resolving the configuration only as needed).Vampire
08/29/2024, 8:33 PMVampire
08/29/2024, 8:35 PM"classpath" to antTaskClasspath,
"loaderref" to antTaskClasspath,
it does not hurt to do it on each task invocation as the same instance will be reused as long as the full classpath stays the sameKelvin Chung
08/29/2024, 8:37 PMVampire
08/29/2024, 8:42 PMloaderref is sufficient to achieve what is necessary in an efficient way.Vampire
08/29/2024, 8:44 PM