You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Blaine Simpson <bl...@admc.com> on 2022/09/02 00:35:27 UTC

programmatic resolve not working transitively

I am quite stuck.  Any help would be appreciated.  The specified artifact
is resolved, but though the specified Configuration and
DependencyDescriptor report isTransitive true, the resolve reports show
that only the directly specified artifact (first level) is resolved.  When
I compare this to the same setup done with Ant, Ant resolves the transitive
artifacts.  I'm using this as test artifact to
resolve:  org.apache.maven#maven-mercury;3.0-alpha-2.

The /* commented code blocks */ below shows alternative configs that I've
tried and which didn't change anything.


My code is Groovy:
        final IvySettings settings = new IvySettings()
        // Default ~/.ivy2 caching.  No ivy.settings file involved.
        org.apache.ivy.plugins.resolver.URLResolver urlResolver =
          new org.apache.ivy.plugins.resolver.URLResolver()
        // allows keyword [organisation] to be .->/ transformed vendor:
        urlResolver.m2compatible = true
        urlResolver.name = 'on-demand'
        urlResolver.addArtifactPattern(urlPattern ?:
          "$IBiblioResolver.DEFAULT_M2_ROOT$IBiblioResolver.M2_PATTERN")
        settings.defaultCache = IvyUtil.cacheDir
        settings.addResolver urlResolver
        settings.defaultResolver = urlResolver.name
        final Ivy ivy = Ivy.newInstance settings

        long millis = System.currentTimeMillis()
        ModuleDescriptor md = new
DefaultModuleDescriptor(ModuleRevisionId.newInstance(
          'caller', 'all-caller', 'working' + millis.toString()[-2..-1]),
          'integration', null, true)
        /* DefaultModuleDescriptor md =
DefaultModuleDescriptor.newDefaultInstance(
          ModuleRevisionId.newInstance('caller', 'all-caller', 'working'))
*/
        final newConf = new Configuration('default')
System.err.println "##################  ${newConf.isTransitive()}
 ##################"
        md.addConfiguration(newConf)
        md.lastModified = millis
        DefaultDependencyDescriptor dd =
          new DefaultDependencyDescriptor(md, mrid, false, false, true)
          // params #3,4,5:
          // force (for version precedence), changing (for snapshot,etc.),
transitive for last 3
System.err.println "******************  ${dd.isTransitive()}
 ***************"
        dd.addDependencyConfiguration 'default', '*'
        md.addDependency dd
        // Must do if not pulling non-classifier jar:
        Map<String,String> exAtts
        if (classer != null) exAtts = [('m:classifier'):classer]
        dd.addDependencyArtifact('*',
          new DefaultDependencyArtifactDescriptor(dd, mrid.name, 'jar',
'jar', null, exAtts))
          // Params 3,4,5,6 are type, ext, URL, extraAtts map
        ResolveReport report = ivy.resolve md,
          new ResolveOptions(
        /*
            // codenarc-disable DuplicateListLiteral
            confs:['default'] as String[],
            // codenarc-enable DuplicateListLiteral
            validate:true,
            transitive:true,
            download:false,
            outputReport:false,
        )
        */
        ).setTransitive(true).setConfs(['default'] as String[])
        // .url always null
        //println("${report.artifacts.size()} artifacts with URLs: "
          //+ "${report.artifacts.collect() { it.url }}"
        println("${report.artifacts.size()} artifacts downloaded " +
          "$report.downloadSize bytes for $mrid/$classer")