ant-ivy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Coene <maarten_co...@yahoo.com>
Subject Re: Programmatically resolving dependencies
Date Thu, 15 Oct 2009 20:52:26 GMT
It's hard to tell what's going wrong, but maybe you could try to configure Ivy to use your
"local-maven-repo" as default resolver?
settings.setDefaultResolver("local-maven-repo");

Maarten




----- Original Message ----
From: dreedyman <dennis.reedy@gmail.com>
To: ivy-user@ant.apache.org
Sent: Thu, October 15, 2009 10:37:20 PM
Subject: Programmatically resolving dependencies


Hi,

I am starting to use Ivy as part of an infrastructure that will be
provisioning software services in runtime. Services will be identified by an
artifact id (groupId:artifactId[:classifier]:version) and be resolved in
order to instantiate them.

I started trying to use the maven-embedder but became quite shocked to see
the number of dependencies required to resolve transitive dependencies. I
really like the simplicity the Ivy project offers, and would like to see if
I cant get past some initial hurdles. I am sure I have placed these hurdles
in fromt of me, since I know I'm not doing something correctly. I'm hoping
that someone can point to what I'm doing wrong. 

(One important aspect of work is I need to obtain the classpath of resolved
artifacts, and have chosen to go the programmatic route as opposed to using
Ant.)

My simple first steps involved creating the Ivy environment and trying to
resolve from the local maven repository. My assumption is that I can use a
Maven pom file directly, and not set up ivy.xml. 

File pom = // a provided maven pom

// Create a FileSystemResolver pointing to the local maven repository
FileSystemResolver fsResolver = new FileSystemResolver()
fsResolver.name = "local-maven-repo"
fsResolver.m2compatible = true
fsResolver.local = true
fsResolver.addArtifactPattern(
"${System.getProperty("user.home")}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).jar")
fsResolver.addIvyPattern(
"${System.getProperty("user.home")}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).pom")

settings.addResolver fsResolver

Ivy ivy = Ivy.newInstance(settings)
ivy.getLoggerEngine().pushLogger(new
DefaultMessageLogger(Message.MSG_VERBOSE));

for(String s : ivy.settings.getResolverNames())
    println "==== Resolver: ${s}"
        
DefaultModuleDescriptor md =
    DefaultModuleDescriptor.newDefaultInstance(
        ModuleRevisionId.newInstance(art.groupId,
                                     art.artifactId + "-caller",
                                     "working"))
DefaultDependencyDescriptor dd =
    new DefaultDependencyDescriptor(md,
                                  
ModuleRevisionId.newInstance(art.groupId,
                                                                
art.artifactId,
                                                                
art.version),
                                    false,
                                    false,
                                    true);
md.addDependency(dd);
def confs = ["default"]
ResolveOptions resolveOptions = new ResolveOptions().setConfs(confs as
String[]);
ResolveReport report = ivy.resolve(ivyFile.toURL(), resolveOptions);
for(ArtifactDownloadReport dlReport : report.allArtifactsReports) {
    File f = dlReport.localFile
    if(f!=null) {
        if(classPath.length()>0)
            classPath.append(File.pathSeparator)
        classPath.append(f.path)
    }
}

I am passing in an artifact that has a defined dependency that needs to be
resolved transitively. Ivy doesnt seem to be able to resolve the dependency:

==== Resolver: local-maven-repo
:: loading settings :: url =
jar:file:/Users/dreedy/.m2/repository/org/apache/ivy/ivy/2.1.0-rc2/ivy-2.1.0-rc2.jar!/org/apache/ivy/core/settings/ivysettings.xml
using pom parser to parse
file:/Users/dreedy/dev/src/rioproj/rio/branches/maven-work/examples/calculator/pom.xml
ERROR: unknown resolver null
:: resolving dependencies :: org.rioproject.examples#calculator;1.0
    confs: [default]
    validate = true
    refresh = false
resolving dependencies for configuration 'default'
== resolving dependencies for org.rioproject.examples#calculator;1.0
[default]
== resolving dependencies for org.rioproject.examples#calculator;1.0
[runtime]
== resolving dependencies for org.rioproject.examples#calculator;1.0
[compile]
== resolving dependencies
org.rioproject.examples#calculator;1.0->org.rioproject#rio;4.0-M3
[compile->master(*)]
ERROR: unknown resolver null
ERROR: no resolver found for org.rioproject#rio: check your configuration
== resolving dependencies
org.rioproject.examples#calculator;1.0->org.rioproject#rio;4.0-M3
[compile->compile(*)]
== resolving dependencies
org.rioproject.examples#calculator;1.0->org.rioproject#rio;4.0-M3
[runtime->runtime(*)]
== resolving dependencies for org.rioproject.examples#calculator;1.0
[master]
no default ivy user dir defined: set to /Users/dreedy/.ivy2
no default cache defined: set to /Users/dreedy/.ivy2/cache
    resolved ivy file produced in
/Users/dreedy/.ivy2/cache/resolved-org.rioproject.examples-calculator-1.0.xml
:: downloading artifacts ::
:: resolution report :: resolve 35ms :: artifacts dl 1ms
    :: modules in use:
    ---------------------------------------------------------------------
    |                  |            modules            ||   artifacts   |
    |       conf       | number| search|dwnlded|evicted|| number|dwnlded|
    ---------------------------------------------------------------------
    |      default     |   1   |   0   |   0   |   0   ||   0   |   0   |
    ---------------------------------------------------------------------
WARN:     ::::::::::::::::::::::::::::::::::::::::::::::
WARN:     ::          UNRESOLVED DEPENDENCIES         ::
WARN:     ::::::::::::::::::::::::::::::::::::::::::::::
WARN:     :: org.rioproject#rio;4.0-M3: no resolver found for
org.rioproject#rio: check your configuration
WARN:     ::::::::::::::::::::::::::::::::::::::::::::::

    report for org.rioproject.examples#calculator;1.0 default produced in
/Users/dreedy/.ivy2/cache/org.rioproject.examples-calculator-default.xml
    resolve done (35ms resolve - 1ms download)

:: problems summary ::
:::: WARNINGS
        ::::::::::::::::::::::::::::::::::::::::::::::

        ::          UNRESOLVED DEPENDENCIES         ::

        ::::::::::::::::::::::::::::::::::::::::::::::

        :: org.rioproject#rio;4.0-M3: no resolver found for org.rioproject#rio:
check your configuration

        ::::::::::::::::::::::::::::::::::::::::::::::


:::: ERRORS
    unknown resolver null

    unknown resolver null

    no resolver found for org.rioproject#rio: check your configuration


-- 
View this message in context: http://www.nabble.com/Programmatically-resolving-dependencies-tp25915616p25915616.html
Sent from the ivy-user mailing list archive at Nabble.com.


      

Mime
View raw message