ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1165117 - in /ant/ivy/core/trunk: ./ doc/ doc/resolver/ doc/settings/ src/java/org/apache/ivy/core/settings/ src/java/org/apache/ivy/plugins/repository/jar/ src/java/org/apache/ivy/plugins/resolver/ test/ test/java/org/apache/ivy/plugins/r...
Date Sun, 04 Sep 2011 21:33:39 GMT
Author: hibou
Date: Sun Sep  4 21:33:39 2011
New Revision: 1165117

URL: http://svn.apache.org/viewvc?rev=1165117&view=rev
Log:
IVY-1312:
 - implementation, test and documentation of the jar resolver

Added:
    ant/ivy/core/trunk/doc/resolver/jar.html   (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java 
 (with props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java   (with
props)
    ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java   (with props)
    ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java   (with
props)
Modified:
    ant/ivy/core/trunk/CHANGES.txt
    ant/ivy/core/trunk/build.xml
    ant/ivy/core/trunk/doc/settings/resolvers.html
    ant/ivy/core/trunk/doc/toc.json
    ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties
    ant/ivy/core/trunk/test/   (props changed)

Modified: ant/ivy/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=1165117&r1=1165116&r2=1165117&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Sun Sep  4 21:33:39 2011
@@ -127,6 +127,7 @@ for detailed view of each issue, please 
 - NEW: ivy:resolve and post resole task can now have inlined dependencies declaration.
 - NEW: Import Bushel into Ivy core (IVY-1241)
 - NEW: An new resolver 'mirroredurl' which can handle a list of mirrored URL repositories
(IVY-468)
+- NEW: Support for a jar resolver (IVY-1312)
 
 - IMPROVEMENT: ivy:makepom ignores the artifact type in generated dependencies (IVY-1229)
(thanks to Douglas Palmer)
 - IMPROVEMENT: ivy:makepom now honors exclusion of artifacts in generated pom files (IVY-1294)
(thanks to Jens Rohloff)

Modified: ant/ivy/core/trunk/build.xml
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/build.xml?rev=1165117&r1=1165116&r2=1165117&view=diff
==============================================================================
--- ant/ivy/core/trunk/build.xml (original)
+++ ant/ivy/core/trunk/build.xml Sun Sep  4 21:33:39 2011
@@ -431,6 +431,15 @@
         <ant dir="${basedir}/test/test-repo" target="generate-bundles" />
 	</target>
 
+    <target name="prepare-test-jar-repositories" unless="skip.test">
+        <jar destfile="${basedir}/test/jar-repos/jarrepo1.jar" >
+            <fileset dir="${basedir}/test/repositories/1" />
+        </jar>
+        <jar destfile="${basedir}/test/jar-repos/jarrepo1_subdir.jar">
+            <fileset dir="${basedir}/test/repositories" includes="1/**/*" />
+        </jar>
+    </target>
+
 	<target name="test-internal" depends="build-test, init-tests, prepare-osgi-tests" unless="skip.test">
         <mkdir dir="${test.xml.dir}" />
     	

Added: ant/ivy/core/trunk/doc/resolver/jar.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/resolver/jar.html?rev=1165117&view=auto
==============================================================================
--- ant/ivy/core/trunk/doc/resolver/jar.html (added)
+++ ant/ivy/core/trunk/doc/resolver/jar.html Sun Sep  4 21:33:39 2011
@@ -0,0 +1,89 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<!--
+   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.    
+-->
+<html>
+<head>
+	<script type="text/javascript">var xookiConfig = {level: 1};</script>	
+	<script type="text/javascript" src="../xooki/xooki.js"></script>
+</head>
+<body>
+	<textarea id="xooki-source">
+<table class="resolver">
+<tr><td class="title">Tag</td><td class="value">jar</td></tr>
+<tr><td class="title">Handle latest</td><td class="value">yes</td></tr>
+<tr><td class="title">Handle publish</td><td class="value">no</td></tr>
+</table><br/>
+
+<span class="since">since 2.3</span>
+
+<span class="tagdoc" id="ivysettings.resolvers.jar">This resolver uses a specified
jar resolve ivy files and artifacts.</span>
+
+This kind of resolver helps the packaging of an entire repository. Since the entire "repository"
jar is expected to be local at some point, the size of a such repository should be considered
to be not too large if it is expected to be remote; hence the artifacts in a such repo should
be little in size.
+
+The configuration of such a resolver is done via specifying the location of the jar, and
through ivy and artifact patterns, indicating where ivy files and artifacts can be found in
the jar. You can indicate a list of patterns which will be checked one after the other. Note
that the patterns MUST NOT start with a slash.
+
+<h1>Attributes</h1>
+This resolver shares the <a href="../settings/resolvers.html#common">common attributes</a>
of standard resolvers.
+<table class="ivy-attributes">
+<thead>
+    <tr><th class="ivy-att">Attribute</th><th class="ivy-att-desc">Description</th><th
class="ivy-att-req">Required</th></tr>
+</thead>
+<tbody>
+    <tr><td>file</td><td>the absolute path of the jar</td>
+        <td>One of 'file' or 'url' is required</td></tr>
+    <tr><td>url</td><td>the url of the jar</td>
+        <td>One of 'file' or 'url' is required</td></tr>
+</tbody>
+</table>
+<h1>Child elements</h1>
+<table class="ivy-children">
+<thead>
+    <tr><th class="ivy-chld">Element</th><th class="ivy-chld-desc">Description</th><th
class="ivy-chld-card">Cardinality</th></tr>
+</thead>
+<tbody>
+    <tr><td>ivy</td><td>defines a pattern for ivy files, using the
pattern attribute</td>
+        <td>0..n</td></tr>
+    <tr><td>artifact</td><td>defines a pattern for artifacts, using
the pattern attribute</td>
+        <td>1..n</td></tr>
+</tbody>
+</table>
+
+<h1>Examples</h1>
+<code type="xml">
+<jar name="my-local-jar-resolver" file="/home/me/myrepo.jar">
+    <ivy pattern="[organisation]/[module]/ivys/ivy-[revision].xml" />
+    <artifact pattern="[organisation]/[module]/[type]s/[artifact]-[revision].[type]" />
+</jar>
+</code>
+A simple local jar repository.
+<hr />
+<code type="xml">
+<jar name="my-remote-jar-resolver" url="http://www.mywebsite.com/dist/myrepo.jar">
+    <ivy pattern="dir_in_jar/subdir_in_jar/[organisation]/[module]/ivys/ivy-[revision].xml"
/>
+    <ivy pattern="dir_in_jar/another_subdir_in_jar/[organisation]/[module]/ivys/ivy-[revision].xml"
/>
+    <artifact pattern="dir_in_jar/subdir_in_jar/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"
/>
+    <artifact pattern="dir_in_jar/another_subdir_in_jar/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"
/>
+    <artifact pattern="dir_in_jar/yet_another_subdir_in_jar/[organisation]/[module]/[type]s/[artifact]-[revision].[type]"
/>
+</jar>
+</code>
+A remote jar repository with multiple ivy and artifact patterns, patterns pointing in some
sub directories in the jar.
+	</textarea>
+<script type="text/javascript">xooki.postProcess();</script>
+</body>
+</html>

Propchange: ant/ivy/core/trunk/doc/resolver/jar.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/doc/resolver/jar.html
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/doc/resolver/jar.html
------------------------------------------------------------------------------
    svn:mime-type = text/html

Modified: ant/ivy/core/trunk/doc/settings/resolvers.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/settings/resolvers.html?rev=1165117&r1=1165116&r2=1165117&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/settings/resolvers.html (original)
+++ ant/ivy/core/trunk/doc/settings/resolvers.html Sun Sep  4 21:33:39 2011
@@ -68,6 +68,7 @@ Here is the list of built-in resolvers:
 <tr><td><a href="../resolver/vfs.html">Vfs</a></td><td>Standard</td><td>Finds
ivy files and artifacts in any repository accessible with <a href="http://jakarta.apache.org/commons/vfs/">apache
commons vfs</a>.</td></tr>
 <tr><td><a href="../resolver/ssh.html">ssh</a></td><td>Standard</td><td>Finds
ivy files and artifacts in any repository accessible with ssh.</td></tr>
 <tr><td><a href="../resolver/sftp.html">sftp</a></td><td>Standard</td><td>Finds
ivy files and artifacts in any repository accessible with sftp.</td></tr>
+<tr><td><a href="../resolver/jar.html">Jar</a></td><td>Standard</td><td>Finds
ivy files and artifacts within a specified jar.</td></tr>
 <tr><td><a href="../resolver/chain.html">Chain</a></td><td>Composite</td><td>Delegates
the finding to a chain of sub resolvers.</td></tr>
 <tr><td><a href="../resolver/dual.html">Dual</a></td><td>Composite</td><td>Delegates
the finding of ivy files to one resolver and of artifacts to another.</td></tr>
 <tr><td><a href="../resolver/obr.html">OBR</a></td><td>Standard</td><td>Resolve
modules as OSGi bundles listed by an OSGi obr.xml.</td></tr>

Modified: ant/ivy/core/trunk/doc/toc.json
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/toc.json?rev=1165117&r1=1165116&r2=1165117&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/toc.json (original)
+++ ant/ivy/core/trunk/doc/toc.json Sun Sep  4 21:33:39 2011
@@ -359,7 +359,14 @@
                               },
                               {
                                 "id":"resolver/vfs",
-                                "title":"vfs",
+                                "title":"vfs resolver",
+                                "children": [
+
+                                  ]
+                              },
+                              {
+                                "id":"resolver/jar",
+                                "title":"Jar resolver",
                                 "children": [
 
                                   ]

Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties?rev=1165117&r1=1165116&r2=1165117&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/typedef.properties Sun Sep  4
21:33:39 2011
@@ -26,6 +26,7 @@ ssh         = org.apache.ivy.plugins.res
 sftp        = org.apache.ivy.plugins.resolver.SFTPResolver
 vsftp       = org.apache.ivy.plugins.resolver.VsftpResolver
 vfs         = org.apache.ivy.plugins.resolver.VfsResolver
+jar         = org.apache.ivy.plugins.resolver.JarResolver
 cache		= org.apache.ivy.plugins.resolver.CacheResolver
 packager	= org.apache.ivy.plugins.resolver.packager.PackagerResolver
 obr         = org.apache.ivy.osgi.obr.OBRResolver

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java?rev=1165117&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java Sun
Sep  4 21:33:39 2011
@@ -0,0 +1,89 @@
+/*
+ *  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.plugins.repository.jar;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+import org.apache.ivy.plugins.repository.AbstractRepository;
+import org.apache.ivy.plugins.repository.RepositoryCopyProgressListener;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.TransferEvent;
+import org.apache.ivy.util.FileUtil;
+
+public class JarRepository extends AbstractRepository {
+
+    private RepositoryCopyProgressListener progress = new RepositoryCopyProgressListener(this);
+
+    private JarFile jarFile;
+
+    public void setJarFile(JarFile jarFile) {
+        this.jarFile = jarFile;
+    }
+
+    public Resource getResource(String source) throws IOException {
+        return new JarResource(jarFile, source);
+    }
+
+    protected RepositoryCopyProgressListener getProgressListener() {
+        return progress;
+    }
+
+    public void get(String source, File destination) throws IOException {
+        fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
+        try {
+            ZipEntry entry = jarFile.getEntry(source);
+            if (entry == null) {
+                throw new FileNotFoundException();
+            }
+            getProgressListener().setTotalLength(new Long(entry.getSize()));
+            FileUtil.copy(jarFile.getInputStream(entry), destination, getProgressListener());
+        } catch (IOException ex) {
+            fireTransferError(ex);
+            throw ex;
+        } catch (RuntimeException ex) {
+            fireTransferError(ex);
+            throw ex;
+        } finally {
+            getProgressListener().setTotalLength(null);
+        }
+    }
+
+    public List/* <String> */list(String parent) throws IOException {
+        ZipEntry parentEntry = jarFile.getEntry(parent);
+        if (parentEntry == null || !parentEntry.isDirectory()) {
+            return null;
+        }
+        List/* <String> */children = new ArrayList();
+        Enumeration entries = jarFile.entries();
+        while (entries.hasMoreElements()) {
+            ZipEntry entry = (ZipEntry) entries.nextElement();
+            if (entry.getName().startsWith(parent) && entry.getName().equals(parentEntry.getName()))
{
+                children.add(entry.getName());
+            }
+        }
+        return children;
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarRepository.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java?rev=1165117&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java Sun
Sep  4 21:33:39 2011
@@ -0,0 +1,69 @@
+/*
+ *  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.plugins.repository.jar;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+
+import org.apache.ivy.plugins.repository.Resource;
+
+public class JarResource implements Resource {
+
+    private final JarFile jarFile;
+
+    private final String path;
+
+    private ZipEntry entry;
+
+    public JarResource(JarFile jarFile, String path) {
+        this.jarFile = jarFile;
+        this.path = path;
+        entry = jarFile.getEntry(path);
+    }
+
+    public String getName() {
+        return path;
+    }
+
+    public long getLastModified() {
+        return entry.getTime();
+    }
+
+    public long getContentLength() {
+        return entry.getSize();
+    }
+
+    public boolean exists() {
+        return entry != null;
+    }
+
+    public boolean isLocal() {
+        return true;
+    }
+
+    public Resource clone(String cloneName) {
+        return new JarResource(jarFile, cloneName);
+    }
+
+    public InputStream openStream() throws IOException {
+        return jarFile.getInputStream(entry);
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/repository/jar/JarResource.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java?rev=1165117&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java Sun Sep 
4 21:33:39 2011
@@ -0,0 +1,89 @@
+/*
+ *  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.plugins.resolver;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.jar.JarFile;
+
+import org.apache.ivy.core.cache.CacheResourceOptions;
+import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.report.ArtifactDownloadReport;
+import org.apache.ivy.plugins.repository.Resource;
+import org.apache.ivy.plugins.repository.jar.JarRepository;
+import org.apache.ivy.plugins.repository.url.URLResource;
+
+public class JarResolver extends RepositoryResolver {
+
+    public JarResolver() {
+        setRepository(new JarRepository());
+    }
+
+    public String getTypeName() {
+        return "jar";
+    }
+
+    public void setFile(String jarFile) {
+        setJarFile(new File(jarFile));
+    }
+
+    public void setUrl(String jarUrl) {
+        URL url;
+        try {
+            url = new URL(jarUrl);
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("the jar repository " + getName()
+                    + " has an malformed url : " + jarUrl + " (" + e.getMessage() + ")");
+        }
+
+        ArtifactDownloadReport report;
+        EventManager eventManager = getEventManager();
+        try {
+            if (eventManager != null) {
+                getRepository().addTransferListener(eventManager);
+            }
+            Resource jarResource = new URLResource(url);
+            CacheResourceOptions options = new CacheResourceOptions();
+            report = getRepositoryCacheManager().downloadRepositoryResource(jarResource,
+                "jarrepository", "jar", "jar", options, getRepository());
+        } finally {
+            if (eventManager != null) {
+                getRepository().removeTransferListener(eventManager);
+            }
+        }
+        setJarFile(report.getLocalFile());
+    }
+
+    public JarRepository getJarRepository() {
+        return (JarRepository) super.getRepository();
+    }
+
+    private void setJarFile(File jarLocalFile) {
+        JarFile jar;
+        try {
+            jar = new JarFile(jarLocalFile);
+        } catch (IOException e) {
+            throw new RuntimeException("the jar repository " + getName() + " could not be
read ("
+                    + e.getMessage() + ")", e);
+        }
+        getJarRepository().setJarFile(jar);
+    }
+
+}

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/resolver/JarResolver.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Propchange: ant/ivy/core/trunk/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Sep  4 21:33:39 2011
@@ -0,0 +1 @@
+jar-repos

Added: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java?rev=1165117&view=auto
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java (added)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java Sun
Sep  4 21:33:39 2011
@@ -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.plugins.resolver;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.ivy.core.cache.DefaultRepositoryCacheManager;
+import org.apache.ivy.core.event.EventManager;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.id.ModuleRevisionId;
+import org.apache.ivy.core.resolve.ResolveData;
+import org.apache.ivy.core.resolve.ResolveEngine;
+import org.apache.ivy.core.resolve.ResolveOptions;
+import org.apache.ivy.core.resolve.ResolvedModuleRevision;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.core.sort.SortEngine;
+import org.apache.ivy.util.CacheCleaner;
+
+public class JarResolverTest extends TestCase {
+
+    private IvySettings settings;
+
+    private File cache;
+
+    private ResolveEngine engine;
+
+    private ResolveData data;
+
+    private DefaultRepositoryCacheManager cacheManager;
+
+    protected void setUp() throws Exception {
+        settings = new IvySettings();
+        engine = new ResolveEngine(settings, new EventManager(), new SortEngine(settings));
+        cache = new File("build/cache");
+        data = new ResolveData(engine, new ResolveOptions());
+        cache.mkdirs();
+        settings.setDefaultCache(cache);
+        cacheManager = (DefaultRepositoryCacheManager) settings.getDefaultRepositoryCacheManager();
+    }
+
+    protected void tearDown() throws Exception {
+        CacheCleaner.deleteDir(cache);
+    }
+
+    public void testSimpleFile() throws Exception {
+        JarResolver resolver = new JarResolver();
+        resolver.setName("jarresolver1");
+        resolver.setSettings(settings);
+        resolver.setFile(new File("test/jar-repos/jarrepo1.jar").getAbsolutePath());
+        resolver.addIvyPattern("[organisation]/[module]/ivys/ivy-[revision].xml");
+        resolver.addArtifactPattern("[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
+        ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
+                false), data);
+        assertNotNull(rmr);
+
+    }
+
+    public void testSubdirInFile() throws Exception {
+        JarResolver resolver = new JarResolver();
+        resolver.setName("jarresolver1_subdir");
+        resolver.setSettings(settings);
+        resolver.setFile(new File("test/jar-repos/jarrepo1_subdir.jar").getAbsolutePath());
+        resolver.addIvyPattern("1/[organisation]/[module]/ivys/ivy-[revision].xml");
+        resolver.addArtifactPattern("1/[organisation]/[module]/[type]s/[artifact]-[revision].[type]");
+
+        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org1", "mod1.1", "1.0");
+        ResolvedModuleRevision rmr = resolver.getDependency(new DefaultDependencyDescriptor(mrid,
+                false), data);
+        assertNotNull(rmr);
+
+    }
+}

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/resolver/JarResolverTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message