You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2014/01/04 14:06:39 UTC
svn commit: r1555344 [1/3] - in /ant/ivy/core/trunk: ./ META-INF/
src/java/org/apache/ivy/ant/ src/java/org/apache/ivy/core/cache/
src/java/org/apache/ivy/core/pack/ src/java/org/apache/ivy/core/report/
src/java/org/apache/ivy/core/resolve/ src/java/or...
Author: hibou
Date: Sat Jan 4 13:06:37 2014
New Revision: 1555344
URL: http://svn.apache.org/r1555344
Log:
Add support for "packed" artifacts: .pack.gz bundles in an OSGi P2 repository for instance
Added:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java (with props)
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/
- copied from r1554557, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilter.java
- copied, changed from r1554557, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java
- copied, changed from r1554557, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/filter/
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/filter/OSGiFilterTest.java
- copied, changed from r1554557, ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java
ant/ivy/core/trunk/test/repositories/1/packaging/
- copied from r1554632, ant/ivy/core/trunk/test/repositories/1/compression/
ant/ivy/core/trunk/test/test-p2/packed/
ant/ivy/core/trunk/test/test-p2/packed/artifacts.xml (with props)
ant/ivy/core/trunk/test/test-p2/packed/content.xml (with props)
ant/ivy/core/trunk/test/test-p2/packed/plugins/
ant/ivy/core/trunk/test/test-p2/packed/plugins/org.junit_4.10.0.v4_10_0_v20120426-0900.jar.pack.gz (with props)
Removed:
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/RequirementFilterParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementFilter.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/RequirementFilterTest.java
ant/ivy/core/trunk/test/repositories/1/compression/
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/META-INF/MANIFEST.MF
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheDownloadOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/AndFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/CompareFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/NotFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OrFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/OBRXMLWriter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/Requirement.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementAdapter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Artifact.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2ArtifactParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2Descriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/p2/P2MetadataParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AbstractOSGiResolver.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/AggregatedRepoDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ArtifactReportManifestIterable.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/BundleRepoDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/EditableRepoDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/ModuleDescriptorWrapper.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/repo/RepoDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/PluginAdapter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/updatesite/UpdateSiteLoader.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/report/XmlReportWriter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyCachePathTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/report/ResolveReportTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/retrieve/RetrieveTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/core/ManifestParserTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/p2/P2DescriptorTest.java
ant/ivy/core/trunk/test/repositories/1/packaging/module1/ivys/ivy-1.0.xml
ant/ivy/core/trunk/test/repositories/1/packaging/module2/ivys/ivy-1.0.xml
ant/ivy/core/trunk/test/repositories/1/packaging/module3/ivys/ivy-1.0.xml
ant/ivy/core/trunk/test/repositories/1/packaging/module4/ivys/ivy-1.0.xml
ant/ivy/core/trunk/test/repositories/1/packaging/module5/ivys/ivy-1.0.xml
ant/ivy/core/trunk/test/repositories/1/packaging/module6/ivys/ivy-1.0.xml
Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sat Jan 4 13:06:37 2014
@@ -150,6 +150,7 @@ for detailed view of each issue, please
- NEW: symlinkmass feature based on symlink feature of ivy:retrieve (IVY-1252) (Thanks to Gene Smith)
- NEW: Agent authentication for SSH and SFTP transports (IVY-1421)
- NEW: New OSGi resolver 'osgi-agg': a chain resolver dedicated to better handle OSGi dependencies
+- NEW: Add support for "packed" artifacts: .pack.gz bundles in an OSGi P2 repository for instance
- IMPROVEMENT: New LockStrategy available based on NIO FileLocks (IVY-1424)
- IMPROVEMENT: Optional <include> ivysettings directives (IVY-1392) (thanks to Yanus Poluektovich)
@@ -171,6 +172,7 @@ for detailed view of each issue, please
- FIX: Correct application of mediators (ie. override) during conflict resolution (IVY-1455)
- FIX: Fix revision number mapping across namespaces (IVY-1423)
- FIX: fix a NPE when loading a composite P2 repository with no children
+- FIX: fix missing configuration when fixdeps is used with a partial resolve
2.3.0
=====================================
Modified: ant/ivy/core/trunk/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/META-INF/MANIFEST.MF?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/META-INF/MANIFEST.MF (original)
+++ ant/ivy/core/trunk/META-INF/MANIFEST.MF Sat Jan 4 13:06:37 2014
@@ -58,6 +58,7 @@ Export-Package: org.apache.ivy;version="
org.apache.ivy.core.module.descriptor;version="2.0.0",
org.apache.ivy.core.module.id;version="2.0.0",
org.apache.ivy.core.module.status;version="2.0.0",
+ org.apache.ivy.core.pack;version="2.4.0",
org.apache.ivy.core.publish;version="2.0.0",
org.apache.ivy.core.report;version="2.0.0",
org.apache.ivy.core.repository;version="2.0.0",
@@ -67,8 +68,8 @@ Export-Package: org.apache.ivy;version="
org.apache.ivy.core.settings;version="2.0.0",
org.apache.ivy.core.sort;version="2.0.0",
org.apache.ivy.osgi.core;version="2.3.0",
+ org.apache.ivy.osgi.filter;version="2.3.0",
org.apache.ivy.osgi.obr;version="2.3.0",
- org.apache.ivy.osgi.obr.filter;version="2.3.0",
org.apache.ivy.osgi.obr.xml;version="2.3.0",
org.apache.ivy.osgi.p2;version="2.3.0",
org.apache.ivy.osgi.repo;version="2.3.0",
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyCachePath.java Sat Jan 4 13:06:37 2014
@@ -75,8 +75,8 @@ public class IvyCachePath extends IvyCac
for (Iterator iter = getArtifactReports().iterator(); iter.hasNext();) {
ArtifactDownloadReport a = (ArtifactDownloadReport) iter.next();
File f = a.getLocalFile();
- if (isUncompress() && a.getUncompressedLocalDir() != null) {
- f = a.getUncompressedLocalDir();
+ if (a.getUnpackedLocalFile() != null) {
+ f = a.getUnpackedLocalFile();
}
addToPath(path, f);
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyPostResolveTask.java Sat Jan 4 13:06:37 2014
@@ -76,8 +76,6 @@ public abstract class IvyPostResolveTask
private boolean changing = false;
- private boolean uncompress;
-
private IvyResolve resolve = new IvyResolve();
public boolean isUseOrigin() {
@@ -96,14 +94,6 @@ public abstract class IvyPostResolveTask
this.log = log;
}
- public boolean isUncompress() {
- return uncompress;
- }
-
- public void setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- }
-
public IvyDependency createDependency() {
return resolve.createDependency();
}
@@ -325,7 +315,6 @@ public abstract class IvyPostResolveTask
resolve.setLog(getLog());
resolve.setSettingsRef(getSettingsRef());
resolve.setResolveMode(getResolveMode());
- resolve.setUncompress(uncompress);
return resolve;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResolve.java Sat Jan 4 13:06:37 2014
@@ -89,8 +89,6 @@ public class IvyResolve extends IvyTask
private String log = ResolveOptions.LOG_DEFAULT;
- private boolean uncompress = false;
-
private boolean checkIfChanged = true; //for backward compatibility
private List/* <IvyDependency> */dependencies = new ArrayList();
@@ -195,14 +193,6 @@ public class IvyResolve extends IvyTask
this.log = log;
}
- public boolean isUncompress() {
- return uncompress;
- }
-
- public void setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- }
-
/**
* @deprecated Use {@link #setFailureProperty(String)} instead
*/
@@ -455,8 +445,7 @@ public class IvyResolve extends IvyTask
.setTransitive(transitive)
.setResolveMode(resolveMode)
.setResolveId(resolveId)
- .setCheckIfChanged(checkIfChanged)
- .setUncompress(uncompress);
+ .setCheckIfChanged(checkIfChanged);
}
public String getModule() {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyRetrieve.java Sat Jan 4 13:06:37 2014
@@ -110,7 +110,6 @@ public class IvyRetrieve extends IvyPost
.setMakeSymlinks(symlink)
.setMakeSymlinksInMass(symlinkmass)
.setResolveId(getResolveId())
- .setUncompress(isUncompress())
.setMapper(mapper == null ? null : new MapperAdapter(mapper)));
int targetsCopied = report.getNbrArtifactsCopied();
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheDownloadOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheDownloadOptions.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheDownloadOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/CacheDownloadOptions.java Sat Jan 4 13:06:37 2014
@@ -23,8 +23,6 @@ public class CacheDownloadOptions {
private boolean force = false;
- private boolean uncompress = false;
-
public DownloadListener getListener() {
return listener;
}
@@ -42,13 +40,4 @@ public class CacheDownloadOptions {
this.force = force;
return this;
}
-
- public boolean isUncompress() {
- return uncompress;
- }
-
- public CacheDownloadOptions setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- return this;
- }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/cache/DefaultRepositoryCacheManager.java Sat Jan 4 13:06:37 2014
@@ -18,10 +18,9 @@
package org.apache.ivy.core.cache;
import java.io.File;
-import java.io.FileOutputStream;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -29,12 +28,9 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.util.Date;
-import java.util.Enumeration;
import java.util.Iterator;
import java.util.Map;
import java.util.regex.Pattern;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.IvyPatternHelper;
@@ -45,6 +41,9 @@ import org.apache.ivy.core.module.descri
import org.apache.ivy.core.module.id.ArtifactRevisionId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.module.id.ModuleRules;
+import org.apache.ivy.core.pack.ArchivePacking;
+import org.apache.ivy.core.pack.PackagingManager;
+import org.apache.ivy.core.pack.StreamPacking;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.core.report.DownloadStatus;
import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
@@ -68,7 +67,6 @@ import org.apache.ivy.plugins.repository
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.repository.ResourceDownloader;
import org.apache.ivy.plugins.repository.ResourceHelper;
-import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.AbstractResolver;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
@@ -129,6 +127,8 @@ public class DefaultRepositoryCacheManag
private ModuleDescriptorMemoryCache memoryModuleDescrCache;
+ private PackagingManager packagingManager = new PackagingManager();
+
public DefaultRepositoryCacheManager() {
}
@@ -144,6 +144,7 @@ public class DefaultRepositoryCacheManag
public void setSettings(IvySettings settings) {
this.settings = settings;
+ packagingManager.setSettings(settings);
}
public File getIvyFileInCache(ModuleRevisionId mrid) {
@@ -1009,8 +1010,8 @@ public class DefaultRepositoryCacheManag
adr.setDownloadTimeMillis(System.currentTimeMillis() - start);
}
}
- if (options.isUncompress() && adr.getDownloadStatus() != DownloadStatus.FAILED) {
- uncompressArtifact(artifact, adr, options);
+ if (adr.getDownloadStatus() != DownloadStatus.FAILED) {
+ unpackArtifact(artifact, adr, options);
}
if (listener != null) {
listener.endArtifactDownload(this, artifact, adr, archiveFile);
@@ -1021,84 +1022,27 @@ public class DefaultRepositoryCacheManag
}
}
- private void uncompressArtifact(Artifact artifact, ArtifactDownloadReport adr,
+ private void unpackArtifact(Artifact artifact, ArtifactDownloadReport adr,
CacheDownloadOptions options) {
- String compression = artifact.getExtraAttribute("compression");
- if (compression == null) {
- // not declared as compressed, nothing to do
+ Artifact unpacked = packagingManager.getUnpackedArtifact(artifact);
+ if (unpacked == null) {
+ // nothing to unpack
return;
}
- // the artifact for the folder of the uncompressed data
- Artifact uncompressed = adr.buildUncompressedArtifact();
-
- File archiveFile = getArchiveFileInCache(uncompressed, null, false);
+ File archiveFile = getArchiveFileInCache(unpacked, null, false);
if (archiveFile.exists() && !options.isForce()) {
- adr.setUncompressedLocalDir(archiveFile);
+ adr.setUnpackedLocalFile(archiveFile);
} else {
- if (compression.equals("zip") || compression.equals("jar") || compression.equals("war")) {
- Message.info("\tUncompressing " + artifact.getId());
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile(adr.getLocalFile());
- Enumeration entries = zipFile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
- File f = new File(archiveFile, entry.getName());
- Message.verbose("\t\texpanding " + entry.getName() + " to " + f);
-
- // create intermediary directories - sometimes zip don't add them
- File dirF = f.getParentFile();
- if (dirF != null) {
- dirF.mkdirs();
- }
-
- if (entry.isDirectory()) {
- f.mkdirs();
- } else {
- InputStream in = zipFile.getInputStream(entry);
- OutputStream out = new FileOutputStream(f);
- try {
- byte[] buffer = new byte[1024];
- int length = 0;
- while ((length = in.read(buffer)) >= 0) {
- out.write(buffer, 0, length);
- }
- } finally {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
- }
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- f.setLastModified(entry.getTime());
- }
- adr.setUncompressedLocalDir(archiveFile);
- } catch (Exception e) {
- Message.debug(e);
- adr.setDownloadStatus(DownloadStatus.FAILED);
- adr.setDownloadDetails("The compressed artifact " + artifact.getId()
- + " could not be uncompressed (" + e.getMessage() + ")");
- } finally {
- if (zipFile != null) {
- try {
- zipFile.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- } else {
+ Message.info("\tUnpacking " + artifact.getId());
+ try {
+ packagingManager.unpackArtifact(artifact, adr.getLocalFile(), archiveFile);
+ adr.setUnpackedLocalFile(archiveFile);
+ } catch (Exception e) {
+ Message.debug(e);
adr.setDownloadStatus(DownloadStatus.FAILED);
- adr.setDownloadDetails("Compression algorithm " + compression
- + " is not supported, " + artifact.getId() + " won't be uncompressed");
+ adr.setDownloadDetails("The packed artifact " + artifact.getId()
+ + " could not be unpacked (" + e.getMessage() + ")");
}
}
}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+public abstract class ArchivePacking {
+
+ public abstract String[] getNames();
+
+ public abstract void unpack(InputStream packed, File dest) throws IOException;
+
+ public abstract String getUnpackedExtension(String ext);
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ArchivePacking.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.jar.Pack200.Unpacker;
+import java.util.zip.GZIPInputStream;
+
+public class Pack200Packing extends StreamPacking {
+
+ private static final String[] NAMES = {"pack200"};
+
+ @Override
+ public String[] getNames() {
+ return NAMES;
+ }
+
+ @Override
+ public String getUnpackedExtension(String ext) {
+ if (ext.endsWith("pack.gz")) {
+ return ext.substring(0, ext.length() - 7);
+ }
+ if (ext.endsWith("pack")) {
+ return ext.substring(0, ext.length() - 4);
+ }
+ return ext;
+ }
+
+ @Override
+ public InputStream unpack(InputStream packed) throws IOException {
+ BufferedInputStream buffered = new BufferedInputStream(packed);
+ buffered.mark(4);
+ byte[] magic = new byte[4];
+ buffered.read(magic, 0, 4);
+ buffered.reset();
+
+ InputStream in = buffered;
+
+ if (magic[0] == (byte) 0x1F && magic[1] == (byte) 0x8B && magic[2] == (byte) 0x08) {
+ // this is a gziped pack200
+ in = new GZIPInputStream(in);
+ }
+
+ Unpacker unpacker = Pack200.newUnpacker();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ JarOutputStream jar = new JarOutputStream(baos);
+ unpacker.unpack(in, jar);
+ jar.close();
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/Pack200Packing.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.ivy.core.module.descriptor.Artifact;
+import org.apache.ivy.core.module.descriptor.DefaultArtifact;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.IvySettingsAware;
+import org.apache.ivy.util.Message;
+
+public class PackagingManager implements IvySettingsAware {
+
+ private IvySettings settings;
+
+ public void setSettings(IvySettings settings) {
+ this.settings = settings;
+ }
+
+ public Artifact getUnpackedArtifact(Artifact artifact) {
+ String packaging = artifact.getExtraAttribute("packaging");
+ if (packaging == null) {
+ // not declared as packed, nothing to do
+ return null;
+ }
+
+ String ext = artifact.getExt();
+
+ String[] packings = packaging.split(",");
+ for (int i = packings.length - 1; i >= 1; i--) {
+ ArchivePacking packing = settings.getPackingRegistry().get(packings[i]);
+ if (packing == null) {
+ throw new IllegalStateException("Unknown packing type '" + packings[i]
+ + "' in the packing chain: " + packaging);
+ }
+ if (!(packing instanceof StreamPacking)) {
+ throw new IllegalStateException("Unsupported archive only packing type '"
+ + packings[i] + "' in the streamed chain: " + packaging);
+ }
+ ext = ((StreamPacking) packing).getUnpackedExtension(ext);
+ }
+ ArchivePacking packing = settings.getPackingRegistry().get(packings[0]);
+ if (packing == null) {
+ throw new IllegalStateException("Unknown packing type '" + packings[0]
+ + "' in the packing chain: " + packaging);
+ }
+ ext = packing.getUnpackedExtension(ext);
+
+ DefaultArtifact unpacked = new DefaultArtifact(artifact.getModuleRevisionId(),
+ artifact.getPublicationDate(), artifact.getName(),
+ artifact.getType() + "_unpacked", ext);
+
+ return unpacked;
+ }
+
+ public void unpackArtifact(Artifact artifact, File localFile, File archiveFile) throws IOException {
+ String packaging = artifact.getExtraAttribute("packaging");
+ if (packaging == null) {
+ // not declared as packed, nothing to do
+ return;
+ }
+
+ String[] packings = packaging.split(",");
+ Message.info("\tUnpacking " + artifact.getId());
+ InputStream in = null;
+ try {
+ in = new FileInputStream(localFile);
+ for (int i = packings.length - 1; i >= 1; i--) {
+ ArchivePacking packing = settings.getPackingRegistry().get(packings[i]);
+ if (packing == null) {
+ throw new IllegalStateException("Unknown packing type '" + packings[i]
+ + "' in the packing chain: " + packaging);
+ }
+ if (!(packing instanceof StreamPacking)) {
+ throw new IllegalStateException("Unsupported archive only packing type '"
+ + packings[i] + "' in the streamed chain: " + packaging);
+ }
+ in = ((StreamPacking) packing).unpack(in);
+ }
+ ArchivePacking packing = settings.getPackingRegistry().get(packings[0]);
+ if (packing == null) {
+ throw new IllegalStateException("Unknown packing type '" + packings[0]
+ + "' in the packing chain: " + packaging);
+ }
+ packing.unpack(in, archiveFile);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackagingManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class PackingRegistry {
+
+ private Map<String, ArchivePacking> packings = new HashMap<String, ArchivePacking>();
+
+ public PackingRegistry() {
+ // register defaults
+ register(new ZipPacking());
+ register(new Pack200Packing());
+ }
+
+ public void register(ArchivePacking packing) {
+ for (String name : packing.getNames()) {
+ packings.put(name, packing);
+ }
+ }
+
+ public ArchivePacking get(String type) {
+ return packings.get(type);
+ }
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/PackingRegistry.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.ivy.util.FileUtil;
+
+public abstract class StreamPacking extends ArchivePacking {
+
+ public abstract InputStream unpack(InputStream packed) throws IOException;
+
+ @Override
+ public void unpack(InputStream packed, File dest) throws IOException {
+ FileUtil.copy(unpack(packed), dest, null);
+ }
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/StreamPacking.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.core.pack;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+import org.apache.ivy.util.FileUtil;
+import org.apache.ivy.util.Message;
+
+public class ZipPacking extends ArchivePacking {
+
+ private static final String[] NAMES = {"zip", "jar", "war"};
+
+ @Override
+ public String[] getNames() {
+ return NAMES;
+ }
+
+ @Override
+ public String getUnpackedExtension(String ext) {
+ if (ext.endsWith("zip") || ext.endsWith("jar") || ext.endsWith("war")) {
+ return ext.substring(0, ext.length() - 3);
+ }
+ return ext;
+ }
+
+ @Override
+ public void unpack(InputStream packed, File dest) throws IOException {
+ ZipInputStream zip = null;
+ try {
+ zip = new ZipInputStream(packed);
+ ZipEntry entry = null;
+ while (((entry = zip.getNextEntry()) != null)) {
+ File f = new File(dest, entry.getName());
+ Message.verbose("\t\texpanding " + entry.getName() + " to " + f);
+
+ // create intermediary directories - sometimes zip don't add them
+ File dirF = f.getParentFile();
+ if (dirF != null) {
+ dirF.mkdirs();
+ }
+
+ if (entry.isDirectory()) {
+ f.mkdirs();
+ } else {
+ FileOutputStream out = new FileOutputStream(f);
+ try {
+ FileUtil.copy(zip, out, null, false);
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ f.setLastModified(entry.getTime());
+ }
+ } finally {
+ if (zip != null) {
+ try {
+ zip.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/core/pack/ZipPacking.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ArtifactDownloadReport.java Sat Jan 4 13:06:37 2014
@@ -56,7 +56,7 @@ public class ArtifactDownloadReport {
private long downloadTimeMillis;
- private File uncompressedLocalDir;
+ private File unpackedLocalFile;
public ArtifactDownloadReport(Artifact artifact) {
this.artifact = artifact;
@@ -158,17 +158,12 @@ public class ArtifactDownloadReport {
return DownloadStatus.SUCCESSFUL == downloadStatus;
}
- public Artifact buildUncompressedArtifact() {
- return new DefaultArtifact(artifact.getModuleRevisionId(), artifact.getPublicationDate(),
- artifact.getName(), artifact.getType() + "_uncompressed", "");
+ public void setUnpackedLocalFile(File unpackedLocalFile) {
+ this.unpackedLocalFile = unpackedLocalFile;
}
- public void setUncompressedLocalDir(File uncompressedLocalDir) {
- this.uncompressedLocalDir = uncompressedLocalDir;
- }
-
- public File getUncompressedLocalDir() {
- return uncompressedLocalDir;
+ public File getUnpackedLocalFile() {
+ return unpackedLocalFile;
}
public int hashCode() {
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/report/ResolveReport.java Sat Jan 4 13:06:37 2014
@@ -335,7 +335,7 @@ public class ResolveReport {
*/
private String[] getExtendingConfs(String extended) {
String[] allConfs = md.getConfigurationsNames();
- Set/* <String> */extendingConfs = new HashSet();
+ Set<String> extendingConfs = new HashSet<String>();
extendingConfs.add(extended);
for (int i = 0; i < allConfs.length; i++) {
gatherExtendingConfs(extendingConfs, allConfs[i], extended);
@@ -343,7 +343,7 @@ public class ResolveReport {
return (String[]) extendingConfs.toArray(new String[extendingConfs.size()]);
}
- private boolean gatherExtendingConfs(Set/* <String> */extendingConfs, String conf,
+ private boolean gatherExtendingConfs(Set<String> extendingConfs, String conf,
String extended) {
if (extendingConfs.contains(conf)) {
return true;
@@ -370,14 +370,14 @@ public class ResolveReport {
}
public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings,
- List/* <ModuleId> */midToKeep) {
+ List<ModuleId> midToKeep) {
DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
md.getStatus(), new Date());
// copy configurations
- String[] resolvedConf = getConfigurations();
- for (int i = 0; i < resolvedConf.length; i++) {
- fixedmd.addConfiguration(new Configuration(resolvedConf[i]));
+ List<String> resolvedConfs = Arrays.asList(getConfigurations());
+ for (String conf : resolvedConfs) {
+ fixedmd.addConfiguration(new Configuration(conf));
}
if (midToKeep != null && !midToKeep.isEmpty()) {
@@ -387,13 +387,18 @@ public class ResolveReport {
if (midToKeep.contains(deps[i].getDependencyId())) {
DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
deps[i].getDependencyRevisionId(), true, false, false);
- String[] confs = deps[i].getModuleConfigurations();
- for (int j = 0; j < confs.length; j++) {
- String[] extendedConf = getExtendingConfs(confs[j]);
- String[] depConfs = deps[i].getDependencyConfigurations(confs[j]);
- for (int k = 0; k < extendedConf.length; k++) {
- for (int l = 0; l < depConfs.length; l++) {
- dep.addDependencyConfiguration(extendedConf[k], depConfs[l]);
+ List<String> confs = Arrays.asList(deps[i].getModuleConfigurations());
+ if (confs.size() == 1 && confs.get(0).equals("*")) {
+ confs = resolvedConfs;
+ }
+ for (String conf : confs) {
+ String[] extendedConfs = getExtendingConfs(conf);
+ String[] depConfs = deps[i].getDependencyConfigurations(conf);
+ for (String extendedConf : extendedConfs) {
+ if (resolvedConfs.contains(extendedConf)) {
+ for (String depConf : depConfs) {
+ dep.addDependencyConfiguration(extendedConf, depConf);
+ }
}
}
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/DownloadOptions.java Sat Jan 4 13:06:37 2014
@@ -22,17 +22,7 @@ import org.apache.ivy.core.LogOptions;
public class DownloadOptions extends LogOptions {
- private boolean uncompress;
-
public DownloadOptions() {
}
- public DownloadOptions setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- return this;
- }
-
- public boolean isUncompress() {
- return uncompress;
- }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveEngine.java Sat Jan 4 13:06:37 2014
@@ -330,7 +330,6 @@ public class ResolveEngine {
DownloadOptions downloadOptions = new DownloadOptions();
downloadOptions.setLog(options.getLog());
- downloadOptions.setUncompress(options.isUncompress());
downloadArtifacts(report, options.getArtifactFilter(), downloadOptions);
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/resolve/ResolveOptions.java Sat Jan 4 13:06:37 2014
@@ -117,7 +117,6 @@ public class ResolveOptions extends LogO
* True if the resolve should compare the new resolution against the previous report
**/
private boolean checkIfChanged = false;
- private boolean uncompress;
public ResolveOptions() {
}
@@ -307,13 +306,4 @@ public class ResolveOptions extends LogO
return moduleId.getOrganisation() + "-" + moduleId.getName();
}
- public ResolveOptions setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- return this;
- }
-
- public boolean isUncompress() {
- return uncompress;
- }
-
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveEngine.java Sat Jan 4 13:06:37 2014
@@ -131,8 +131,8 @@ public class RetrieveEngine {
for (Iterator iter = artifactsToCopy.keySet().iterator(); iter.hasNext();) {
ArtifactDownloadReport artifact = (ArtifactDownloadReport) iter.next();
File archive = artifact.getLocalFile();
- if (options.isUncompress() && artifact.getUncompressedLocalDir() != null) {
- archive = artifact.getUncompressedLocalDir();
+ if (artifact.getUnpackedLocalFile() != null) {
+ archive = artifact.getUnpackedLocalFile();
}
if (archive == null) {
Message.verbose("\tno local file available for " + artifact + ": skipping");
@@ -333,7 +333,7 @@ public class RetrieveEngine {
Artifact artifact = adr.getArtifact();
String ext = artifact.getExt();
- if (options.isUncompress() && adr.getUncompressedLocalDir() != null) {
+ if (adr.getUnpackedLocalFile() != null) {
ext = "";
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/retrieve/RetrieveOptions.java Sat Jan 4 13:06:37 2014
@@ -86,7 +86,6 @@ public class RetrieveOptions extends Log
private String resolveId;
private FileNameMapper mapper;
- private boolean uncompress;
public RetrieveOptions() {
}
@@ -104,7 +103,6 @@ public class RetrieveOptions extends Log
this.makeSymlinksInMass = options.makeSymlinksInMass;
this.resolveId = options.resolveId;
this.mapper = options.mapper;
- this.uncompress = options.uncompress;
}
public String getDestArtifactPattern() {
@@ -206,12 +204,4 @@ public class RetrieveOptions extends Log
return this;
}
- public boolean isUncompress() {
- return uncompress;
- }
-
- public RetrieveOptions setUncompress(boolean uncompress) {
- this.uncompress = uncompress;
- return this;
- }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/IvySettings.java Sat Jan 4 13:06:37 2014
@@ -53,6 +53,8 @@ import org.apache.ivy.core.module.id.Mod
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.module.id.ModuleRules;
import org.apache.ivy.core.module.status.StatusManager;
+import org.apache.ivy.core.pack.ArchivePacking;
+import org.apache.ivy.core.pack.PackingRegistry;
import org.apache.ivy.core.publish.PublishEngineSettings;
import org.apache.ivy.core.repository.RepositoryManagementEngineSettings;
import org.apache.ivy.core.resolve.ResolveEngineSettings;
@@ -215,6 +217,8 @@ public class IvySettings implements Sort
private String defaultResolveMode = ResolveOptions.RESOLVEMODE_DEFAULT;
+ private PackingRegistry packingRegistry = new PackingRegistry();
+
public IvySettings() {
this(new IvyVariableContainerImpl());
}
@@ -1507,4 +1511,12 @@ public class IvySettings implements Sort
return Namespace.SYSTEM_NAMESPACE;
}
+ public synchronized void addConfigured(ArchivePacking packing) {
+ init(packing);
+ packingRegistry.register(packing);
+ }
+
+ public PackingRegistry getPackingRegistry() {
+ return packingRegistry;
+ }
}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java?rev=1555344&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java Sat Jan 4 13:06:37 2014
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ivy.osgi.core;
+
+import java.net.URI;
+
+public class BundleArtifact {
+
+ private boolean source = false;
+
+ private URI uri;
+
+ private String format;
+
+ public BundleArtifact(boolean source, URI uri, String format) {
+ this.source = source;
+ this.uri = uri;
+ this.format = format;
+ }
+
+ public boolean isSource() {
+ return source;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+}
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleArtifact.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfo.java Sat Jan 4 13:06:37 2014
@@ -17,7 +17,6 @@
*/
package org.apache.ivy.osgi.core;
-import java.net.URI;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
@@ -63,8 +62,6 @@ public class BundleInfo {
private Integer size;
- private URI uri;
-
private boolean isSource = false;
/** the symbolic name of the bundle it is source of */
@@ -73,12 +70,12 @@ public class BundleInfo {
/** the version of the bundle it is source of */
private Version versionTarget;
- private URI sourceURI;
-
private boolean hasInnerClasspath;
private List<String> classpath;
+ private List<BundleArtifact> artifacts = new ArrayList<BundleArtifact>();
+
public BundleInfo(String name, Version version) {
this.symbolicName = name;
this.version = version;
@@ -97,7 +94,7 @@ public class BundleInfo {
builder.append(", version=");
builder.append(version);
builder.append("]");
- if (isSource) {
+ if (symbolicNameTarget != null) {
builder.append(" source of ");
builder.append(symbolicNameTarget);
builder.append("@");
@@ -118,14 +115,6 @@ public class BundleInfo {
return version;
}
- public void setUri(URI uri) {
- this.uri = uri;
- }
-
- public URI getUri() {
- return uri;
- }
-
public void setId(String id) {
this.id = id;
}
@@ -206,14 +195,6 @@ public class BundleInfo {
executionEnvironments.add(name);
}
- public void setSourceURI(URI sourceURI) {
- this.sourceURI = sourceURI;
- }
-
- public URI getSourceURI() {
- return sourceURI;
- }
-
public void setSource(boolean isSource) {
this.isSource = isSource;
}
@@ -254,6 +235,18 @@ public class BundleInfo {
return classpath;
}
+ public void addArtifact(BundleArtifact artifact) {
+ artifacts.add(artifact);
+ }
+
+ public void removeArtifact(BundleArtifact same) {
+ artifacts.remove(same);
+ }
+
+ public List<BundleArtifact> getArtifacts() {
+ return artifacts;
+ }
+
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -263,11 +256,9 @@ public class BundleInfo {
result = prime * result + ((version == null) ? 0 : version.hashCode());
result = prime * result
+ ((executionEnvironments == null) ? 0 : executionEnvironments.hashCode());
- result = prime * result + (isSource ? 1231 : 1237);
result = prime * result
+ ((symbolicNameTarget == null) ? 0 : symbolicNameTarget.hashCode());
result = prime * result + ((versionTarget == null) ? 0 : versionTarget.hashCode());
- result = prime * result + ((sourceURI == null) ? 0 : sourceURI.hashCode());
return result;
}
@@ -334,13 +325,6 @@ public class BundleInfo {
} else if (!versionTarget.equals(other.versionTarget)) {
return false;
}
- if (sourceURI == null) {
- if (other.sourceURI != null) {
- return false;
- }
- } else if (!sourceURI.equals(other.sourceURI)) {
- return false;
- }
if (hasInnerClasspath != other.hasInnerClasspath) {
return false;
}
@@ -365,7 +349,7 @@ public class BundleInfo {
}
public Set<BundleRequirement> getImports() {
- Set<BundleRequirement> set = new LinkedHashSet<BundleRequirement> ();
+ Set<BundleRequirement> set = new LinkedHashSet<BundleRequirement>();
for (BundleRequirement requirement : requirements) {
if (requirement.getType().equals(PACKAGE_TYPE)) {
set.add(requirement);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java Sat Jan 4 13:06:37 2014
@@ -111,19 +111,30 @@ public class BundleInfoAdapter {
requirementAsDependency(md, bundle, exportedPkgNames);
if (baseUri != null) {
- // TODO handle:
- // Eclipse-BundleShape ::= ( 'jar' | 'dir' )
- String compression = bundle.hasInnerClasspath() ? "zip" : null;
- URI uri = bundle.getUri();
- if (uri != null) {
- 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",
- compression);
- md.addArtifact(CONF_NAME_DEFAULT, artifact);
+ for (BundleArtifact bundleArtifact : bundle.getArtifacts()) {
+ String type = "jar";
+ String ext = "jar";
+ String packaging = null;
+ if (bundle.hasInnerClasspath()) {
+ packaging = "zip";
+ }
+ if ("packed".equals(bundleArtifact.getFormat())) {
+ ext = "jar.pack.gz";
+ if (packaging != null) {
+ packaging += ",pack200";
+ } else {
+ packaging = "pack200";
+ }
+ }
+ if (bundleArtifact.isSource()) {
+ type = "source";
+ }
+ URI uri = bundleArtifact.getUri();
+ if (uri != null) {
+ DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, type, ext,
+ packaging);
+ md.addArtifact(CONF_NAME_DEFAULT, artifact);
+ }
}
}
@@ -153,7 +164,7 @@ public class BundleInfoAdapter {
}
public static DefaultArtifact buildArtifact(ModuleRevisionId mrid, URI baseUri, URI uri,
- String type, String compression) {
+ String type, String ext, String packaging) {
DefaultArtifact artifact;
if ("ivy".equals(uri.getScheme())) {
artifact = decodeIvyURI(uri);
@@ -162,11 +173,11 @@ public class BundleInfoAdapter {
uri = baseUri.resolve(uri);
}
Map<String, String> extraAtt = new HashMap<String, String>();
- if (compression != null) {
- extraAtt.put("compression", compression);
+ if (packaging != null) {
+ extraAtt.put("packaging", packaging);
}
try {
- artifact = new DefaultArtifact(mrid, null, mrid.getName(), type, "jar", new URL(
+ artifact = new DefaultArtifact(mrid, null, mrid.getName(), type, ext, new URL(
uri.toString()), extraAtt);
} catch (MalformedURLException e) {
throw new RuntimeException("Unable to make the uri into the url", e);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/ManifestParser.java Sat Jan 4 13:06:37 2014
@@ -73,30 +73,39 @@ public class ManifestParser {
public static BundleInfo parseJarManifest(InputStream jarStream) throws IOException,
ParseException {
- final JarInputStream jis = new JarInputStream(jarStream);
- final BundleInfo parseManifest = parseManifest(jis.getManifest());
- jis.close();
- return parseManifest;
+ JarInputStream jis = new JarInputStream(jarStream);
+ Manifest manifest = jis.getManifest();
+ if (manifest == null) {
+ return null;
+ }
+ BundleInfo bundleInfo = parseManifest(manifest);
+ return bundleInfo;
}
public static BundleInfo parseManifest(File manifestFile) throws IOException, ParseException {
- final FileInputStream fis = new FileInputStream(manifestFile);
- final BundleInfo parseManifest = parseManifest(fis);
- fis.close();
- return parseManifest;
+ FileInputStream fis = new FileInputStream(manifestFile);
+ try {
+ BundleInfo parseManifest = parseManifest(fis);
+ return parseManifest;
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
}
public static BundleInfo parseManifest(String manifest) throws IOException, ParseException {
- final ByteArrayInputStream bais = new ByteArrayInputStream(manifest.getBytes("UTF-8"));
- final BundleInfo parseManifest = parseManifest(bais);
+ ByteArrayInputStream bais = new ByteArrayInputStream(manifest.getBytes("UTF-8"));
+ BundleInfo parseManifest = parseManifest(bais);
bais.close();
return parseManifest;
}
public static BundleInfo parseManifest(InputStream manifestStream) throws IOException,
ParseException {
- final BundleInfo parseManifest = parseManifest(new Manifest(manifestStream));
- manifestStream.close();
+ BundleInfo parseManifest = parseManifest(new Manifest(manifestStream));
return parseManifest;
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java?rev=1555344&r1=1555343&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java Sat Jan 4 13:06:37 2014
@@ -65,7 +65,7 @@ public class OSGiManifestParser implemen
Manifest m = new Manifest(res.openStream());
BundleInfo bundleInfo = ManifestParser.parseManifest(m);
try {
- bundleInfo.setUri(new URI(res.getName()));
+ bundleInfo.addArtifact(new BundleArtifact(false, new URI(res.getName()), null));
} catch (URISyntaxException e) {
throw new RuntimeException("Unsupported repository, resources names are not uris", e);
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/AndFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/AndFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/AndFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/AndFilter.java Sat Jan 4 13:06:37 2014
@@ -15,9 +15,10 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
+
+import java.util.Map;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
public class AndFilter extends MultiOperatorFilter {
@@ -25,11 +26,21 @@ public class AndFilter extends MultiOper
super();
}
- public AndFilter(RequirementFilter[] filters) {
+ public AndFilter(OSGiFilter[] filters) {
super(filters);
}
protected char operator() {
return '&';
}
+
+ @Override
+ public boolean eval(Map<String, String> properties) {
+ for (OSGiFilter filter : getSubFilters()) {
+ if (!filter.eval(properties)) {
+ return false;
+ }
+ }
+ return true;
+ }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/CompareFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/CompareFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/CompareFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/CompareFilter.java Sat Jan 4 13:06:37 2014
@@ -15,37 +15,25 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
+import java.util.Map;
-public class CompareFilter extends RequirementFilter {
+public class CompareFilter extends OSGiFilter {
- // enum 1.5 wrote in java 1.4
- public static class Operator {
+ public static enum Operator {
- public static Operator EQUALS = new Operator();
+ EQUALS("="), LOWER_THAN("<"), LOWER_OR_EQUAL("<="), GREATER_THAN(">"), GREATER_OR_EQUAL(
+ ">=");
- public static Operator LOWER_THAN = new Operator();
+ private String op;
- public static Operator LOWER_OR_EQUAL = new Operator();
-
- public static Operator GREATER_THAN = new Operator();
-
- public static Operator GREATER_OR_EQUAL = new Operator();
+ private Operator(String op) {
+ this.op = op;
+ }
public String toString() {
- if (this == EQUALS)
- return "=";
- if (this == GREATER_THAN)
- return ">";
- if (this == GREATER_OR_EQUAL)
- return ">=";
- if (this == LOWER_THAN)
- return "<";
- if (this == LOWER_OR_EQUAL)
- return "<=";
- return super.toString();
+ return op;
}
}
@@ -81,6 +69,29 @@ public class CompareFilter extends Requi
builder.append(")");
}
+ @Override
+ public boolean eval(Map<String, String> properties) {
+ String actualValue = properties.get(leftValue);
+ if (actualValue == null) {
+ return false;
+ }
+ int diff = rightValue.compareTo(actualValue);
+ switch (operator) {
+ case EQUALS:
+ return diff == 0;
+ case GREATER_THAN:
+ return diff > 0;
+ case GREATER_OR_EQUAL:
+ return diff >= 0;
+ case LOWER_OR_EQUAL:
+ return diff <= 0;
+ case LOWER_THAN:
+ return diff < 0;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
public int hashCode() {
final int prime = 31;
int result = 1;
@@ -124,5 +135,4 @@ public class CompareFilter extends Requi
}
return true;
}
-
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/MultiOperatorFilter.java Sat Jan 4 13:06:37 2014
@@ -15,24 +15,23 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
import java.util.ArrayList;
import java.util.List;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
-public abstract class MultiOperatorFilter extends RequirementFilter {
+public abstract class MultiOperatorFilter extends OSGiFilter {
- private List<RequirementFilter> subFilters = new ArrayList<RequirementFilter>();
+ private List<OSGiFilter> subFilters = new ArrayList<OSGiFilter>();
public MultiOperatorFilter() {
// default constructor
}
- public MultiOperatorFilter(RequirementFilter[] filters) {
+ public MultiOperatorFilter(OSGiFilter[] filters) {
for (int i = 0; i < filters.length; i++) {
- RequirementFilter filter = filters[i];
+ OSGiFilter filter = filters[i];
add(filter);
}
}
@@ -42,24 +41,24 @@ public abstract class MultiOperatorFilte
public void append(StringBuffer builder) {
builder.append('(');
builder.append(operator());
- for (RequirementFilter filter : subFilters) {
+ for (OSGiFilter filter : subFilters) {
filter.append(builder);
}
builder.append(')');
}
- public void add(RequirementFilter subFilter2) {
+ public void add(OSGiFilter subFilter2) {
subFilters.add(subFilter2);
}
- public List<RequirementFilter> getSubFilters() {
+ public List<OSGiFilter> getSubFilters() {
return subFilters;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- for (RequirementFilter subFilter : subFilters) {
+ for (OSGiFilter subFilter : subFilters) {
result = prime * result + ((subFilter == null) ? 0 : subFilter.hashCode());
}
return result;
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/NotFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/NotFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/NotFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/NotFilter.java Sat Jan 4 13:06:37 2014
@@ -15,17 +15,23 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
+
+import java.util.Map;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
public class NotFilter extends UniOperatorFilter {
- public NotFilter(RequirementFilter subFilter) {
+ public NotFilter(OSGiFilter subFilter) {
super(subFilter);
}
protected char operator() {
return '!';
}
+
+ @Override
+ public boolean eval(Map<String, String> properties) {
+ return !getSubFilter().eval(properties);
+ }
}
Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilter.java (from r1554557, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementFilter.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilter.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilter.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementFilter.java&r1=1554557&r2=1555344&rev=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/xml/RequirementFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilter.java Sat Jan 4 13:06:37 2014
@@ -15,9 +15,11 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.xml;
+package org.apache.ivy.osgi.filter;
-public abstract class RequirementFilter {
+import java.util.Map;
+
+public abstract class OSGiFilter {
public String toString() {
StringBuffer builder = new StringBuffer();
@@ -27,4 +29,6 @@ public abstract class RequirementFilter
public abstract void append(StringBuffer builder);
+ public abstract boolean eval(Map<String, String> properties);
+
}
Copied: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java (from r1554557, ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java)
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java?p2=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java&p1=ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java&r1=1554557&r2=1555344&rev=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/obr/filter/RequirementFilterParser.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OSGiFilterParser.java Sat Jan 4 13:06:37 2014
@@ -15,16 +15,15 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
import java.text.ParseException;
-import org.apache.ivy.osgi.obr.filter.CompareFilter.Operator;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
+import org.apache.ivy.osgi.filter.CompareFilter.Operator;
-public class RequirementFilterParser {
+public class OSGiFilterParser {
- public static RequirementFilter parse(String text) throws ParseException {
+ public static OSGiFilter parse(String text) throws ParseException {
return new Parser(text).parse();
}
@@ -68,7 +67,7 @@ public class RequirementFilterParser {
*
* @throws ParseException
*/
- RequirementFilter parse() throws ParseException {
+ OSGiFilter parse() throws ParseException {
return parseFilter();
}
@@ -87,13 +86,13 @@ public class RequirementFilterParser {
}
}
- private RequirementFilter parseFilter() throws ParseException {
+ private OSGiFilter parseFilter() throws ParseException {
skipWhiteSpace();
readNext();
if (c != '(') {
throw new ParseException("Expecting '(' as the start of the filter", pos);
}
- RequirementFilter filter;
+ OSGiFilter filter;
switch (readNext()) {
case '&':
filter = parseAnd();
@@ -116,7 +115,7 @@ public class RequirementFilterParser {
return filter;
}
- private RequirementFilter parseCompare() throws ParseException {
+ private OSGiFilter parseCompare() throws ParseException {
String leftValue = parseCompareValue();
Operator operator = parseCompareOperator();
String rightValue = parseCompareValue();
@@ -163,13 +162,13 @@ public class RequirementFilterParser {
throw new ParseException("Expecting an operator: =, <, <=, > or >=", pos);
}
- private RequirementFilter parseAnd() throws ParseException {
+ private OSGiFilter parseAnd() throws ParseException {
AndFilter filter = new AndFilter();
parseMultiOperator(filter);
return filter;
}
- private RequirementFilter parseOr() throws ParseException {
+ private OSGiFilter parseOr() throws ParseException {
OrFilter filter = new OrFilter();
parseMultiOperator(filter);
return filter;
@@ -192,7 +191,7 @@ public class RequirementFilterParser {
}
}
- private RequirementFilter parseNot() throws ParseException {
+ private OSGiFilter parseNot() throws ParseException {
readNext();
if (c != '(') {
throw new ParseException("The ! operator is expecting a filter", pos);
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OrFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OrFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OrFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/OrFilter.java Sat Jan 4 13:06:37 2014
@@ -15,9 +15,10 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
+
+import java.util.Map;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
public class OrFilter extends MultiOperatorFilter {
@@ -25,11 +26,21 @@ public class OrFilter extends MultiOpera
super();
}
- public OrFilter(RequirementFilter[] filters) {
+ public OrFilter(OSGiFilter[] filters) {
super(filters);
}
protected char operator() {
return '|';
}
+
+ @Override
+ public boolean eval(Map<String, String> properties) {
+ for (OSGiFilter filter : getSubFilters()) {
+ if (filter.eval(properties)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java?rev=1555344&r1=1554557&r2=1555344&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/filter/UniOperatorFilter.java Sat Jan 4 13:06:37 2014
@@ -15,15 +15,14 @@
* limitations under the License.
*
*/
-package org.apache.ivy.osgi.obr.filter;
+package org.apache.ivy.osgi.filter;
-import org.apache.ivy.osgi.obr.xml.RequirementFilter;
-public abstract class UniOperatorFilter extends RequirementFilter {
+public abstract class UniOperatorFilter extends OSGiFilter {
- private final RequirementFilter subFilter;
+ private final OSGiFilter subFilter;
- public UniOperatorFilter(RequirementFilter subFilter) {
+ public UniOperatorFilter(OSGiFilter subFilter) {
this.subFilter = subFilter;
}
@@ -36,7 +35,7 @@ public abstract class UniOperatorFilter
builder.append(")");
}
- public RequirementFilter getSubFilter() {
+ public OSGiFilter getSubFilter() {
return subFilter;
}