DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Ivy resolves downloads but ignores some artifacts (though not modules)

Jakub Holý user avatar by
Jakub Holý
·
Dec. 24, 10 · Interview
Like (0)
Save
Tweet
Share
8.74K Views

Join the DZone community and get the full member experience.

Join For Free

I’ve had a strange issue with Apache Ivy‘s resolve task – it resolved and downloaded all my dependencies but didn’t put some of them to the classpath (via ivy:cachepath) and certainly wouldn’t copy them either (via ivy:retrieve). An indicia was that in the resolve report the number of “artifacts” was zero while the number of “modules” matched the number of the dependencies. The issue was caused by my defaultconfmapping=”*->compile” – it turned out that most modules, as interpreted by Ivy, produce their artifacts only for the configuration “master” and not for compile.

In my case, with ivy.xml (definition of the configurations compile, provided, and test not shown) containing

...
<dependencies defaultconf="compile">
<dependency conf="provided" org="log4j" name="log4j" rev="1.2.14" />
<dependency conf="test" org="net.jakubholy.testing" name="dbunit-embeddedderby-parenttest" rev="1.1.0" />
<dependency conf="test" org="org.mockito" name="mockito-all" rev="1.8.5" />
</dependencies>
...

the test-scoped dependencies net.jakubholy.testing:dbunit-embeddedderby-parenttest:1.1.0 and org.mockito:mockito-all:1.8.5 were included in the classpath together with their dependencies as expected while log4j:log4j:1.2.14 was ignored no matter what I did (even changing its conf to test).

The problem was indicated by <ivy:resolve /> producing an output like:

[ivy:resolve] :: resolution report :: resolve 951ms :: artifacts dl 20ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
| test | 13 | 0 | 0 | 1 || 10 | 0 |
| provided | 1 | 0 | 0 | 0 || 0 | 0 |
| runtime | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------

Troubleshooting

Checking the resolve report in <user home>/.ivy2/cache/resolved-<org>-<artifact>-<revision>.xml revealed the full definition of configurations (included from another file), dependencies and especially dependencies/defaultconfmapping, which was rather useful later. The defaultconfmapping

...
<dependencies defaultconf="compile" defaultconfmapping="*->compile">
...

seemed to be OK but was not, as further exploration revealed.

Next I’ve checked the Ivy descriptor for the log4j “module” generated by Ivy from its pom.xml in .ivy2/cache/log4j/log4j/ivy-1.2.14.xml and its publications tag caught my eye:

<publications>
<artifact name="log4j" type="jar" ext="jar" conf="master"/>
<artifact name="log4j" type="source" ext="jar" conf="sources" m:classifier="sources"/>
</publications>
...

- notice that the JAR artifact (i.e. log4j.jar) is produced only for the configuration ‘master’! But due to the innocently looking default mapping of “*->compile” we are taking into account only artifacts produced in the configuration “compile”, which is zero. Mystery solved!

Fix

The fix (not necessarily the best one) is to include all configurations of interest in the default mapping (either on dependencies or on configurations in ivy.xml):

<dependencies defaultconf="compile" defaultconfmapping="*->compile,master,default">

 

From http://theholyjava.wordpress.com/2010/12/23/ivy-resolve-downloads-but-ignores-some-artifacts-though-not-modules/

Artifact (UML)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How To Build a Spring Boot GraalVM Image
  • Isolating Noisy Neighbors in Distributed Systems: The Power of Shuffle-Sharding
  • Best Practices for Writing Clean and Maintainable Code
  • 7 Ways for Better Collaboration Among Your Testers and Developers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: