Skip to content

Comment out explicit check against M2_PATTERN#13

Merged
eed3si9n merged 2 commits into2.3.x-sbtfrom
wip/mavenmetadata
Jun 26, 2015
Merged

Comment out explicit check against M2_PATTERN#13
eed3si9n merged 2 commits into2.3.x-sbtfrom
wip/mavenmetadata

Conversation

@eed3si9n
Copy link
Member

REF sbt/sbt#2005, and potentially relates to some of the SNAPSHOT issues listed on sbt/sbt#1780.

Ivy checks if the repository patterns ends with M2_PATTERN to see if maven-metadata.xml should be used. Because sbt customizes the pattern, Ivy will end up not using maven-metadata.xml.

/review @jsuereth, @dwijnand

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello! :)

@dwijnand
Copy link
Member

Sorry I've no idea what changing shouldUseMavenMetadata would impact.

@eed3si9n
Copy link
Member Author

@dwijnand I appreciate the candid honesty. It's impossible to keep track of all the details, so feel free to ask for explanation of what's going on. Note that these are facts that I've dug out recently, so might not be 100% accurate.

When Ivy sees dynamic revisions like version range, it queries the repository for the list of all available versions for the given artifact. The method that gets called eventually is listResources -

protected ResolvedResource[] listResources(
Repository repository, ModuleRevisionId mrid, String pattern, Artifact artifact) {
if (shouldUseMavenMetadata(pattern)) {
List revs = listRevisionsWithMavenMetadata(
repository, mrid.getModuleId().getAttributes());
if (revs != null) {
Message.debug("\tfound revs: " + revs);
List rres = new ArrayList();
for (Iterator iter = revs.iterator(); iter.hasNext();) {
String rev = (String) iter.next();
ModuleRevisionId historicalMrid = ModuleRevisionId.newInstance(mrid, rev);
String patternForRev = pattern;
if (rev.endsWith("SNAPSHOT")) {
String snapshotVersion = findSnapshotVersion(historicalMrid);
if (snapshotVersion != null) {
patternForRev = pattern.replaceFirst("\\-\\[revision\\]", "-" + snapshotVersion);
}
}
String resolvedPattern = IvyPatternHelper.substitute(
patternForRev, historicalMrid, artifact);
try {
Resource res = repository.getResource(resolvedPattern);
if ((res != null) && res.exists()) {
rres.add(new ResolvedResource(res, rev));
}
} catch (IOException e) {
Message.warn(
"impossible to get resource from name listed by maven-metadata.xml:"
+ rres + ": " + e.getMessage());
}
}
return (ResolvedResource[]) rres.toArray(new ResolvedResource[rres.size()]);
} else {
// maven metadata not available or something went wrong,
// use default listing capability
return super.listResources(repository, mrid, pattern, artifact);
}
} else {
return super.listResources(repository, mrid, pattern, artifact);
}
}

It first determines that the repository is fully compatible with Maven using shouldUseMavenMetadata(pattern), if it is, it uses maven-metadata.xml that lists out the versions. Otherwise, it tries screen scraping using ApacheURLLister. The Apache screen scraping doesn't work with Bintray, because they've added "#" character to their directory listing. The goal here to make shouldUseMavenMetadata(pattern) more lenient so sbt's dependency resolution can use more accurate maven-metadata.xml.

@dwijnand
Copy link
Member

But why does sbt (not ivy) change the maven pattern?

Also, given a release off of the head of this PR is now in sbt master, this should be merged.

@eed3si9n
Copy link
Member Author

sbt's pattern encodes (_[scalaVersion])(_[sbtVersion]) so we can do cross publishing in Maven sort-of-compatible way. - https://github.com/sbt/sbt/blob/0.13/ivy/src/main/scala/sbt/Resolver.scala#L328-L330

eed3si9n added a commit that referenced this pull request Jun 26, 2015
Comment out explicit check against M2_PATTERN
@eed3si9n eed3si9n merged commit 51cdbbf into 2.3.x-sbt Jun 26, 2015
@eed3si9n eed3si9n deleted the wip/mavenmetadata branch June 26, 2015 21:17
@dwijnand
Copy link
Member

Oh, those. I see. Huh, but that was years ago! Ok thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants