mirror of https://github.com/apache/ant-ivy
Add support for bundle with inner classpath
git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1375562 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99e257660b
commit
e350a38760
|
|
@ -74,6 +74,8 @@ public class BundleInfo {
|
|||
|
||||
private URI sourceURI;
|
||||
|
||||
private boolean hasInnerClasspath;
|
||||
|
||||
public BundleInfo(String name, Version version) {
|
||||
this.symbolicName = name;
|
||||
this.version = version;
|
||||
|
|
@ -225,6 +227,14 @@ public class BundleInfo {
|
|||
return versionTarget;
|
||||
}
|
||||
|
||||
public void setHasInnerClasspath(boolean hasInnerClasspath) {
|
||||
this.hasInnerClasspath = hasInnerClasspath;
|
||||
}
|
||||
|
||||
public boolean hasInnerClasspath() {
|
||||
return hasInnerClasspath;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
|
|
@ -312,6 +322,9 @@ public class BundleInfo {
|
|||
} else if (!sourceURI.equals(other.sourceURI)) {
|
||||
return false;
|
||||
}
|
||||
if (hasInnerClasspath != other.hasInnerClasspath) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,11 @@ import java.net.URISyntaxException;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.ivy.Ivy;
|
||||
|
|
@ -111,14 +113,16 @@ public class BundleInfoAdapter {
|
|||
|
||||
requirementAsDependency(md, bundle, exportedPkgNames);
|
||||
|
||||
String compression = bundle.hasInnerClasspath() ? "zip" : null;
|
||||
URI uri = bundle.getUri();
|
||||
if (uri != null) {
|
||||
DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, "jar");
|
||||
DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, "jar", compression);
|
||||
md.addArtifact(CONF_NAME_DEFAULT, artifact);
|
||||
}
|
||||
URI sourceURI = bundle.getSourceURI();
|
||||
if (sourceURI != null) {
|
||||
DefaultArtifact artifact = buildArtifact(mrid, baseUri, sourceURI, "source");
|
||||
DefaultArtifact artifact = buildArtifact(mrid, baseUri, sourceURI, "source",
|
||||
compression);
|
||||
md.addArtifact(CONF_NAME_DEFAULT, artifact);
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +155,7 @@ public class BundleInfoAdapter {
|
|||
return md;
|
||||
}
|
||||
|
||||
public static DefaultArtifact buildArtifact(ModuleRevisionId mrid, URI baseUri, URI uri, String type) {
|
||||
public static DefaultArtifact buildArtifact(ModuleRevisionId mrid, URI baseUri, URI uri, String type, String compression) {
|
||||
DefaultArtifact artifact;
|
||||
if ("ivy".equals(uri.getScheme())) {
|
||||
artifact = decodeIvyURI(uri);
|
||||
|
|
@ -159,9 +163,13 @@ public class BundleInfoAdapter {
|
|||
if (!uri.isAbsolute()) {
|
||||
uri = baseUri.resolve(uri);
|
||||
}
|
||||
Map extraAtt = new HashMap();
|
||||
if (compression != null) {
|
||||
extraAtt.put("compression", compression);
|
||||
}
|
||||
try {
|
||||
artifact = new DefaultArtifact(mrid, null, mrid.getName(), type, "jar", new URL(
|
||||
uri.toString()), null);
|
||||
uri.toString()), extraAtt);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException("Unable to make the uri into the url", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,9 @@ public class P2MetadataParser implements XMLInputParser {
|
|||
// });
|
||||
addChild(new TouchpointDataHandler(), new ChildElementHandler() {
|
||||
public void childHanlded(DelegetingHandler child) throws SAXParseException {
|
||||
if (((TouchpointDataHandler) child).zipped) {
|
||||
bundleInfo.setHasInnerClasspath(true);
|
||||
}
|
||||
if (!bundleInfo.isSource()) {
|
||||
// we only care about parsing the manifest if it is a source
|
||||
return;
|
||||
|
|
@ -685,11 +688,14 @@ public class P2MetadataParser implements XMLInputParser {
|
|||
|
||||
String manifest;
|
||||
|
||||
boolean zipped;
|
||||
|
||||
public TouchpointDataHandler() {
|
||||
super(TOUCHPOINTDATA);
|
||||
addChild(new InstructionsHandler(), new ChildElementHandler() {
|
||||
public void childHanlded(DelegetingHandler child) {
|
||||
manifest = ((InstructionsHandler) child).manifest;
|
||||
zipped = ((InstructionsHandler) child).zipped;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -708,12 +714,18 @@ public class P2MetadataParser implements XMLInputParser {
|
|||
|
||||
String manifest;
|
||||
|
||||
boolean zipped;
|
||||
|
||||
public InstructionsHandler() {
|
||||
super(INSTRUCTIONS);
|
||||
addChild(new InstructionHandler(), new ChildElementHandler() {
|
||||
public void childHanlded(DelegetingHandler child) {
|
||||
if (((InstructionHandler) child).key.equals("manifest")) {
|
||||
String key = ((InstructionHandler) child).key;
|
||||
if ("manifest".equals(key)) {
|
||||
manifest = ((InstructionHandler) child).getBufferedChars();
|
||||
} else if ("zipped".equals(key)) {
|
||||
zipped = Boolean.valueOf(
|
||||
((InstructionHandler) child).getBufferedChars().trim()).booleanValue();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue