mirror of https://github.com/apache/ant-ivy
IVY-1656: write inherited dependencies first to preserve resolve order
This commit is contained in:
parent
749dca3c09
commit
1cac02ef6f
|
|
@ -292,12 +292,10 @@ public final class XmlModuleDescriptorUpdater {
|
|||
// according to ivy.xsd, all <dependency> elements must occur before
|
||||
// the <exclude>, <override> or <conflict> elements
|
||||
if (options.isMerge()
|
||||
&& ("exclude".equals(localName) || "override".equals(localName) || "conflict"
|
||||
.equals(localName)) && "ivy-module/dependencies".equals(getContext())) {
|
||||
&& !mergedDependencies
|
||||
&& "ivy-module/dependencies".equals(getContext())) {
|
||||
ModuleDescriptor merged = options.getMergedDescriptor();
|
||||
writeInheritedDependencies(merged);
|
||||
out.println();
|
||||
out.print(getIndent());
|
||||
}
|
||||
|
||||
context.push(qName);
|
||||
|
|
@ -991,7 +989,7 @@ public final class XmlModuleDescriptorUpdater {
|
|||
* just write the inherited items inline, with a comment indicating where they
|
||||
* came from.
|
||||
*/
|
||||
private void writeInheritedItems(ModuleDescriptor merged, InheritableItem[] items,
|
||||
private boolean writeInheritedItems(ModuleDescriptor merged, InheritableItem[] items,
|
||||
ItemPrinter printer, String itemName, boolean includeContainer) {
|
||||
// first categorize inherited items by their source module, so that
|
||||
// we can add some useful comments
|
||||
|
|
@ -1014,6 +1012,10 @@ public final class XmlModuleDescriptorUpdater {
|
|||
newMapping.isEmpty() ? "" : " defaultconfmapping=\"" + newMapping + "\"",
|
||||
(confMappingOverride != null) ? " confmappingoverride=\"" + confMappingOverride + "\"" : ""));
|
||||
context.push(itemName);
|
||||
if ("dependencies".equals(itemName)) {
|
||||
out.println();
|
||||
out.print(getIndent());
|
||||
}
|
||||
justOpen = null;
|
||||
}
|
||||
|
||||
|
|
@ -1039,13 +1041,17 @@ public final class XmlModuleDescriptorUpdater {
|
|||
// restore the prior indent
|
||||
out.print(currentIndent);
|
||||
}
|
||||
|
||||
return hasItems;
|
||||
}
|
||||
|
||||
private void writeInheritanceComment(String itemDescription, Object parentInfo) {
|
||||
PrintWriter out = getWriter();
|
||||
out.println();
|
||||
out.println(getIndent() + "<!-- " + itemDescription + " inherited from " + parentInfo
|
||||
+ " -->");
|
||||
if (!"dependencies".equals(itemDescription)) {
|
||||
out.println();
|
||||
out.print(getIndent());
|
||||
}
|
||||
out.println("<!-- " + itemDescription + " inherited from " + parentInfo + " -->");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1113,8 +1119,11 @@ public final class XmlModuleDescriptorUpdater {
|
|||
private void writeInheritedDependencies(ModuleDescriptor merged) {
|
||||
if (!mergedDependencies) {
|
||||
mergedDependencies = true;
|
||||
writeInheritedItems(merged, getDependencies(merged), DependencyPrinter.INSTANCE,
|
||||
"dependencies", false);
|
||||
InheritableItem[] items = getDependencies(merged);
|
||||
if (writeInheritedItems(merged, items, DependencyPrinter.INSTANCE, "dependencies", false)) {
|
||||
out.println("<!-- dependencies inherited end -->");
|
||||
out.print(getIndent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1149,7 +1158,7 @@ public final class XmlModuleDescriptorUpdater {
|
|||
* a descriptor element name, for example "configurations" or "info"
|
||||
*/
|
||||
private void flushMergedElementsBefore(String moduleElement) {
|
||||
if (options.isMerge() && context.size() == 1 && "ivy-module".equals(context.peek())
|
||||
if (options.isMerge() && "ivy-module".equals(getContext())
|
||||
&& !(mergedConfigurations && mergedDependencies)) {
|
||||
|
||||
// calculate the position of the element in ivy-module
|
||||
|
|
@ -1184,7 +1193,6 @@ public final class XmlModuleDescriptorUpdater {
|
|||
}
|
||||
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
|
||||
String path = getContext();
|
||||
if (options.isMerge()) {
|
||||
ModuleDescriptor merged = options.getMergedDescriptor();
|
||||
|
|
@ -1198,10 +1206,6 @@ public final class XmlModuleDescriptorUpdater {
|
|||
// write inherited configurations after all child configurations
|
||||
writeInheritedConfigurations(merged);
|
||||
break;
|
||||
case "ivy-module/dependencies":
|
||||
// write inherited dependencies after all child dependencies
|
||||
writeInheritedDependencies(merged);
|
||||
break;
|
||||
case "ivy-module":
|
||||
// write any remaining inherited data before we close the
|
||||
// descriptor.
|
||||
|
|
@ -1284,9 +1288,14 @@ public final class XmlModuleDescriptorUpdater {
|
|||
justOpen = null;
|
||||
}
|
||||
|
||||
write("<!--");
|
||||
write(String.valueOf(ch, start, length));
|
||||
write("-->");
|
||||
if (options.isMerge()
|
||||
&& !mergedDependencies
|
||||
&& "ivy-module/dependencies".equals(getContext())) {
|
||||
ModuleDescriptor merged = options.getMergedDescriptor();
|
||||
writeInheritedDependencies(merged);
|
||||
}
|
||||
|
||||
write(new StringBuilder("<!--").append(ch, start, length).append("-->").toString());
|
||||
|
||||
if (inHeader) {
|
||||
write(LINE_SEPARATOR);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
<conf name="extra"/>
|
||||
<!-- overrides conf in parent -->
|
||||
<conf name="default" extends="compile" description="overrides the conf definition in parent descriptor"/>
|
||||
|
||||
|
||||
<!-- configurations inherited from apache#resolve-simple;1.0 -->
|
||||
<conf name="compile" visibility="public"/>
|
||||
</configurations>
|
||||
|
|
@ -39,14 +39,14 @@
|
|||
<publications/>
|
||||
|
||||
<dependencies>
|
||||
<!-- dependencies inherited from apache#resolve-simple;1.0 -->
|
||||
<dependency org="org1" name="mod1.2" rev="2.0" conf="default->default"/>
|
||||
<dependency org="org1" name="mod1.1" rev="2.0" transitive="false" conf="compile->default"/>
|
||||
<!-- dependencies inherited end -->
|
||||
<!-- not in parent -->
|
||||
<dependency org="org2" name="mod2.1" rev="0.3" conf="default->compile(default)"/>
|
||||
<!-- overrides parent -->
|
||||
<dependency org="org1" name="mod1.1" rev="1.1" conf="default,compile->default" transitive="false"/>
|
||||
|
||||
<!-- dependencies inherited from apache#resolve-simple;1.0 -->
|
||||
<dependency org="org1" name="mod1.2" rev="2.0" conf="default->default"/>
|
||||
<dependency org="org1" name="mod1.1" rev="2.0" transitive="false" conf="compile->default"/>
|
||||
</dependencies>
|
||||
|
||||
</ivy-module>
|
||||
</ivy-module>
|
||||
|
|
|
|||
Loading…
Reference in New Issue