ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maarten Coene <maarten_co...@yahoo.com>
Subject Re: svn commit: r1028013 - in /ant/ivy/core/trunk: ./ doc/ doc/use/ src/java/org/apache/ivy/ant/ test/java/org/apache/ivy/ant/ test/repositories/1/org2/mod2.1/ivys/ test/repositories/1/org2/mod2.1/jars/ test/repositories/1/org2/mod2.2/ivys/ test/repositori...
Date Wed, 27 Oct 2010 21:47:28 GMT
Nicolas,

Very nice :-)
Is this related to https://issues.apache.org/jira/browse/IVY-334 ?

Maarten




----- Original Message ----
From: Nicolas Lalevée <nicolas.lalevee@hibnet.org>
To: dev@ant.apache.org
Sent: Wed, October 27, 2010 6:50:27 PM
Subject: Re: svn commit: r1028013 - in /ant/ivy/core/trunk: ./ doc/ doc/use/ 
src/java/org/apache/ivy/ant/ test/java/org/apache/ivy/ant/ 
test/repositories/1/org2/mod2.1/ivys/ test/repositories/1/org2/mod2.1/jars/ 
test/repositories/1/org2/mod2.2/ivys/ test/repositori...

As you may see, I have updated the ant version used because resources used in 
the new feature introduced are since Ant 1.7.0.
I haven't changed Ivy's requirement on Ant though. For me Ivy is still requiring 
Ant 1.6, and can even work with earlier versions. Only if the user want to use 
this new ivy:resources feature, it will require to have an Ant 1.7 minimum.

Nicolas


Le 27 oct. 2010 à 17:57, hibou@apache.org a écrit :

> Author: hibou
> Date: Wed Oct 27 15:57:36 2010
> New Revision: 1028013
> 
> URL: http://svn.apache.org/viewvc?rev=1028013&view=rev
> Log:
> New Ivy Ant datatype: a resource collection compute from an Ivy resolve.
> The basic implementation work, but is not yet a complete clone/merge of 
>ivy:resolve and ivy.xml's <dependencies>
> 
> Added:
>    ant/ivy/core/trunk/doc/use/resources.html
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java
>    ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResourcesTest.java
>    ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/ivys/ivy-0.7.xml
>    ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/jars/mod2.1-0.7.jar
>    ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/ivys/ivy-0.10.xml
>    ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/jars/mod2.2-0.10.jar
> Modified:
>    ant/ivy/core/trunk/doc/toc.json
>    ant/ivy/core/trunk/ivy.xml
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
>    ant/ivy/core/trunk/src/java/org/apache/ivy/ant/antlib.xml
> 
> Modified: ant/ivy/core/trunk/doc/toc.json
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/toc.json?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/doc/toc.json (original)
> +++ ant/ivy/core/trunk/doc/toc.json Wed Oct 27 15:57:36 2010
> @@ -737,6 +737,13 @@
>                             ]
>                         },
>                         {
> +                          "id":"use/resources",
> +                          "title":"resources",
> +                          "children": [
> +
> +                            ]
> +                        },
> +                        {
>                           "id":"use/retrieve",
>                           "title":"retrieve",
>                           "children": [
> 
> Added: ant/ivy/core/trunk/doc/use/resources.html
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/resources.html?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/doc/use/resources.html (added)
> +++ ant/ivy/core/trunk/doc/use/resources.html Wed Oct 27 15:57:36 2010
> @@ -0,0 +1,103 @@
> +<!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">
> +<span class="since">(since 2.3)</span>
> +<span class="since">(Ant 1.7 required)</span>
> +<tt>ivy:resources</tt> is an Ant <a 
>href="http://ant.apache.org/manual/Types/resources.html#collection">resource 
>collection</a>, which files are based on an Ivy resolve, and then can be used 
>with any task which is working with resources like <tt>copy</tt> or 
><tt>import</tt>.
> +
> +This datatype is a sort of clone and merge of both the Ivy <a 
>hef="resolve.html">resolve task</a> and the <a 
>href="../ivyfile/dependencies.html">dependencies</a> element of an ivy.xml file.

>So most of the attributes and xml elements are the same and have the same 
>semantic.
> +
> +<h1>Attributes</h1>
> +<table class="ant">
> +<thead>
> +    <tr><th class="ant-att">Attribute</th><th 
>class="ant-desc">Description</th><th class="ant-req">Required</th></tr>
> +</thead>
> +<tbody>
> +    <tr><td>refresh</td><td>true to force Ivy to resolve dynamic
revision in 
>this resolve process, false to use cached resolved revision</td><td>No. defaults

>to false</td></tr>
> +
> +    <tr><td>resolveMode</td><td>the resolve mode to use for
this dependency 
>resolution process</td><td>No. defaults to using the resolve mode set in the

>[[settings settings]]</td></tr>
> +
> +    <tr><td>changing</td><td>indicates that the module may change
when 
>resolving in inline mode. See <a href="../concept.html#change">cache and change

>management</a> for details. Ignored when resolving in standard mode.</td><td>No.

>Defaults to false.</td></tr>
> +
> +    <tr><td>type</td><td>comma separated list of accepted artifact

>types</td><td>No. defaults to ${ivy.resolve.default.type.filter}</td></tr>
> +
> +    <tr><td>transitive</td><td>true to resolve dependencies
transitively, 
>false otherwise</td><td>No. Defaults to true</td></tr>
> +
> +    <tr><td>showprogress</td><td>true to show dots while downloading,
false 
>otherwise</td><td>No. Defaults to true</td></tr>
> +
> +    <tr><td>validate</td><td>true to force ivy files validation
against 
>ivy.xsd, false to force no validation</td><td>No. Defaults to default ivy
value 
>(as configured in configuration file)</td></tr>
> +
> +    <tr><td>settingsRef</td><td>A reference to the ivy settings
that must be 
>used by this task</td><td>No, 'ivy.instance' is taken by default.</td></tr>
> +
> +    <tr><td>resolveId</td><td>An id which can be used later
to refer to the 
>results of this resolve</td><td>No, defaults to '[org]-[module]'.</td></tr>
> +
> +    <tr><td>log</td><td>the log setting to use during the resolve

>process.<br/>
> +Available options are:
> +<ul><li>default</li> the default log settings, where all usual messages
are 
>output to the console
> +<li>download-only</li> disable all usual messages but download ones. A resolve

>with everything in cache won't output any message.
> +<li>quiet</li> disable all usual messages, making the whole resolve process

>quiet unless errors occur
> +</ul></td><td>No, defaults to 'default'.</td></tr>
> +
> +     <tr><td>checkIfChanged</td><td>When set to true, the resolve
will compare 
>the result with the last resolution done on this module, with those 
>configurations in order to define the property ivy.deps.changed.  Put it to 
>false may provides slightly better performance.</td><td>No, default to 
>'true'</td></tr>
> +</tbody>
> +</table>
> +
> +<h1>Child elements</h1>
> +<table class="ant">
> +<thead>
> +    <tr><th class="ant-att">Element</th><th class="ant-desc">Element</th><th

>class="ant-req">Element</th></tr>
> +</thead>
> +<tbody>
> +    <tr><td><a 
>href="../ivyfile/dependency.html">dependency</a></td><td>declares
a dependency 
>to resolve</td>
> +        <td>0..n</td></tr>
> +    <tr><td><a href="../ivyfile/exclude.html">exclude</a></td><td>excludes

>artifacts, modules or whole organizations from the set of dependencies to 
>resolve</td>
> +        <td>0..n</td></tr>
> +</tbody>
> +</table>
> +
> +<h1>Examples</h1>
> +<h2>Simplest resolved resources</h2>
> +<code><ivy:resources>
> +    <dependency org="org.apache.ivy" name="ivy" rev="2.2.0" />
> +</ivy:resources>
> +</code>
> +<h2>Specific resolved configuration</h2>
> +<code><ivy:resources>
> +    <dependency org="org.apache.ant" name="ant" rev="1.8.0" 
>conf="core,launcher" />
> +    <dependency org="org.apache.ivy" name="ivy" rev="2.2.0" conf="runtime" />
> +</ivy:resources>
> +</code>
> +<h2>Filtering to jars only and excluding a dependency</h2>
> +<code><ivy:resources type="jar">
> +    <dependency org="org.apache.ant" name="ant" rev="1.8.0" 
>conf="core,launcher" />
> +    <dependency org="org.apache.ivy" name="ivy" rev="2.2.0" conf="runtime" />
> +    <exclude org="org.apache.commons" module="commons-loging" />
> +</ivy:resources>
> +</code>
> +</textarea>
> +<script type="text/javascript">xooki.postProcess();</script>
> +</body>
> +</html>
> 
> Modified: ant/ivy/core/trunk/ivy.xml
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/ivy.xml?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/ivy.xml (original)
> +++ ant/ivy/core/trunk/ivy.xml Wed Oct 27 15:57:36 2010
> @@ -43,9 +43,9 @@
>         <artifact name="ivy" type="source" ext="jar" conf="source"/>
>     </publications>
>     <dependencies>
> -        <dependency org="ant" name="ant" rev="1.6.2" 
>conf="default,ant->default"/>
> -        <dependency org="ant" name="ant-nodeps" rev="1.6.2" conf="default"/>
> -        <dependency org="ant" name="ant-trax" rev="1.6.2" conf="default"/>
> +        <dependency org="org.apache.ant" name="ant" rev="1.7.1" 
>conf="default,ant->default"/>
> +        <dependency org="org.apache.ant" name="ant-nodeps" rev="1.7.1" 
>conf="default"/>
> +        <dependency org="org.apache.ant" name="ant-trax" rev="1.7.1" 
>conf="default"/>
>         <dependency org="commons-httpclient" name="commons-httpclient" 
>rev="3.0" conf="default,httpclient->runtime,master" />
>         <dependency org="oro" name="oro" rev="2.0.8" 
>conf="default,oro->default"/>
>         <dependency org="commons-vfs" name="commons-vfs" rev="1.0" 
>conf="default,vfs->default" />
> 
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java 
>(original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/AntMessageLogger.java Wed 
>Oct 27 15:57:36 2010
> @@ -23,6 +23,7 @@ import org.apache.ivy.util.Checks;
> import org.apache.ivy.util.MessageLogger;
> import org.apache.tools.ant.BuildEvent;
> import org.apache.tools.ant.BuildListener;
> +import org.apache.tools.ant.ProjectComponent;
> import org.apache.tools.ant.Task;
> 
> /**
> @@ -44,13 +45,14 @@ public class AntMessageLogger extends Ab
>      * @param ivy
>      *            the ivy instance on which the logger should be registered
>      */
> -    public static void register(Task task, final Ivy ivy) {
> +    public static void register(ProjectComponent task, final Ivy ivy) {
>         MessageLogger current = ivy.getLoggerEngine().peekLogger();
> -        if (current instanceof AntMessageLogger)  {
> -            Task currentTask = ((AntMessageLogger) current).task;
> +        if (current instanceof AntMessageLogger && task instanceof Task
> +                && ((AntMessageLogger) current).task instanceof Task)  {
> +            Task currentTask = (Task) ((AntMessageLogger) current).task;
> 
>             if ((currentTask.getTaskName() != null)
> -                    && currentTask.getTaskName().equals(task.getTaskName()))

{
> +                    && currentTask.getTaskName().equals(((Task) 
>task).getTaskName())) {
>                 // The current AntMessageLogger already logs with the same
>                 // prefix as the given task. So we shouldn't do anything...
>                 return;
> @@ -97,7 +99,7 @@ public class AntMessageLogger extends Ab
> 
>     }
> 
> -    private Task task;
> +    private ProjectComponent task;
> 
>     private long lastProgressFlush = 0;
> 
> @@ -110,7 +112,7 @@ public class AntMessageLogger extends Ab
>      *            the ant project component this message implementation should 
>use for logging. Must
>      *            not be <code>null</code>.
>      */
> -    protected AntMessageLogger(Task task) {
> +    protected AntMessageLogger(ProjectComponent task) {
>         Checks.checkNotNull(task, "task");
>         this.task = task;
>     }
> 
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java 
>(original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyAntSettings.java Wed Oct 
>27 15:57:36 2010
> @@ -35,7 +35,7 @@ import org.apache.ivy.util.url.URLHandle
> import org.apache.ivy.util.url.URLHandlerRegistry;
> import org.apache.tools.ant.BuildException;
> import org.apache.tools.ant.Project;
> -import org.apache.tools.ant.Task;
> +import org.apache.tools.ant.ProjectComponent;
> import org.apache.tools.ant.taskdefs.Property;
> import org.apache.tools.ant.types.DataType;
> 
> @@ -108,7 +108,7 @@ public class IvyAntSettings extends Data
>      * @param  project  TODO add text.
>      * @return  An IvySetting instance.
>      */
> -    public static IvyAntSettings getDefaultInstance(Task task) {
> +    public static IvyAntSettings getDefaultInstance(ProjectComponent task) {
>         Project project = task.getProject();
>         Object defaultInstanceObj = project.getReference("ivy.instance");
>         if (defaultInstanceObj != null
> @@ -232,14 +232,14 @@ public class IvyAntSettings extends Data
>      * Return the configured Ivy instance.
>      * @return Returns the configured Ivy instance.
>      */
> -    public Ivy getConfiguredIvyInstance(Task task) {
> +    public Ivy getConfiguredIvyInstance(ProjectComponent task) {
>         if (ivyEngine == null) {
>             createIvyEngine(task);
>         }
>         return ivyEngine;
>     }
> 
> -    void createIvyEngine(final Task task) {
> +    void createIvyEngine(final ProjectComponent task) {
>         Project project = task.getProject();
>         Property prop = new Property() {
>             public void execute() throws BuildException {
> @@ -291,7 +291,7 @@ public class IvyAntSettings extends Data
>         }
>     }
> 
> -    protected Properties getDefaultProperties(Task task) {
> +    protected Properties getDefaultProperties(ProjectComponent task) {
>         URL url = IvySettings.getDefaultPropertiesURL();
>         // this is copy of loadURL code from ant Property task (not available 
>in 1.5.1)
>         Properties props = new Properties();
> @@ -316,7 +316,7 @@ public class IvyAntSettings extends Data
>      * 
>      * @param variableContainer
>      */
> -    private void defineDefaultSettingFile(IvyVariableContainer 
>variableContainer, Task task) {
> +    private void defineDefaultSettingFile(IvyVariableContainer 
>variableContainer, ProjectComponent task) {
>         String settingsFileName = 
>variableContainer.getVariable("ivy.conf.file");
>         if (settingsFileName != null 
>                 && 
>!settingsFileName.equals(variableContainer.getVariable("ivy.settings.file"))) {
> 
> Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java (added)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java Wed Oct 
>27 15:57:36 2010
> @@ -0,0 +1,95 @@
> +/*
> + *  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.ant;
> +
> +import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
> +import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
> +import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
> +import org.apache.ivy.core.module.id.ModuleRevisionId;
> +import org.apache.tools.ant.BuildException;
> +
> +public class IvyDependency {
> +
> +    private String org;
> +
> +    private String name;
> +
> +    private String rev;
> +
> +    private String branch;
> +
> +    private String conf;
> +
> +    public String getOrg() {
> +        return org;
> +    }
> +
> +    public void setOrg(String org) {
> +        this.org = org;
> +    }
> +
> +    public String getName() {
> +        return name;
> +    }
> +
> +    public void setName(String name) {
> +        this.name = name;
> +    }
> +
> +    public String getRev() {
> +        return rev;
> +    }
> +
> +    public void setRev(String rev) {
> +        this.rev = rev;
> +    }
> +
> +    public String getBranch() {
> +        return branch;
> +    }
> +
> +    public void setBranch(String branch) {
> +        this.branch = branch;
> +    }
> +
> +    public String getConf() {
> +        return conf;
> +    }
> +
> +    public void setConf(String conf) {
> +        this.conf = conf;
> +    }
> +
> +    DependencyDescriptor asDependencyDescriptor(ModuleDescriptor md, String c) 
>{
> +        if (org == null) {
> +            throw new BuildException("'org' is required on ");
> +        }
> +        if (name == null) {
> +            throw new BuildException("'name' is required when using inline 
>mode");
> +        }
> +        ModuleRevisionId mrid = ModuleRevisionId.newInstance(org, name, 
>branch, rev);
> +        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, 
>mrid, false, false, true);
> +        if (conf != null) {
> +            dd.addDependencyConfiguration(c, conf);
> +        } else {
> +            dd.addDependencyConfiguration(c, "*");            
> +        }
> +        return dd;
> +    }
> +
> +}
> 
> Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java (added)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java Wed Oct 27 
>15:57:36 2010
> @@ -0,0 +1,202 @@
> +/*
> + *  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.ant;
> +
> +import java.io.IOException;
> +import java.text.ParseException;
> +import java.util.ArrayList;
> +import java.util.Arrays;
> +import java.util.Collection;
> +import java.util.Iterator;
> +import java.util.List;
> +import java.util.Set;
> +
> +import org.apache.ivy.Ivy;
> +import org.apache.ivy.core.LogOptions;
> +import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
> +import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
> +import org.apache.ivy.core.module.id.ModuleRevisionId;
> +import org.apache.ivy.core.report.ArtifactDownloadReport;
> +import org.apache.ivy.core.report.ConfigurationResolveReport;
> +import org.apache.ivy.core.report.ResolveReport;
> +import org.apache.ivy.core.resolve.ResolveOptions;
> +import org.apache.ivy.util.filter.Filter;
> +import org.apache.ivy.util.filter.FilterHelper;
> +import org.apache.tools.ant.BuildException;
> +import org.apache.tools.ant.types.Reference;
> +import org.apache.tools.ant.types.resources.BaseResourceCollectionWrapper;
> +import org.apache.tools.ant.types.resources.FileResource;
> +
> +public class IvyResources extends BaseResourceCollectionWrapper {
> +
> +    private List/* <IvyDependency> */dependencies = new ArrayList();
> +
> +    private String type = null;
> +
> +    private String pubdate = null;
> +
> +    private boolean useCacheOnly = false;
> +
> +    private boolean transitive = true;
> +
> +    private boolean refresh = false;
> +
> +    private String resolveMode = null;
> +
> +    private String resolveId = null;
> +
> +    private String log = ResolveOptions.LOG_DEFAULT;
> +
> +    private Reference antIvyEngineRef;
> +
> +    public void setType(String type) {
> +        this.type = type;
> +    }
> +
> +    public void setDate(String pubdate) {
> +        this.pubdate = pubdate;
> +    }
> +
> +    public void setPubdate(String pubdate) {
> +        this.pubdate = pubdate;
> +    }
> +
> +    public void setUseCacheOnly(boolean useCacheOnly) {
> +        this.useCacheOnly = useCacheOnly;
> +    }
> +
> +    public void setTransitive(boolean transitive) {
> +        this.transitive = transitive;
> +    }
> +
> +    public void setRefresh(boolean refresh) {
> +        this.refresh = refresh;
> +    }
> +
> +    public void setResolveMode(String resolveMode) {
> +        this.resolveMode = resolveMode;
> +    }
> +
> +    public void setResolveId(String resolveId) {
> +        this.resolveId = resolveId;
> +    }
> +
> +    public void setLog(String log) {
> +        this.log = log;
> +    }
> +
> +    public void setSettingsRef(Reference ref) {
> +        antIvyEngineRef = ref;
> +    }
> +
> +    public void addDependency(IvyDependency dependency) {
> +        dependencies.add(dependency);
> +    }
> +
> +    public boolean isFilesystemOnly() {
> +        return true;
> +    }
> +
> +    protected Collection/* <String> */getAllowedLogOptions() {
> +        return Arrays.asList(new String[] {LogOptions.LOG_DEFAULT, 
>LogOptions.LOG_DOWNLOAD_ONLY,
> +                LogOptions.LOG_QUIET});
> +    }
> +
> +    protected Ivy getIvyInstance() {
> +        Object antIvyEngine;
> +        if (antIvyEngineRef != null) {
> +            antIvyEngine = antIvyEngineRef.getReferencedObject(getProject());
> +            if 
>(!antIvyEngine.getClass().getName().equals(IvyAntSettings.class.getName())) {
> +                throw new BuildException(antIvyEngineRef.getRefId()
> +                        + " doesn't reference an ivy:settings", 
>getLocation());
> +            }
> +            if (!(antIvyEngine instanceof IvyAntSettings)) {
> +                throw new BuildException(antIvyEngineRef.getRefId()
> +                        + " has been defined in a different classloader.  "
> +                        + "Please use the same loader when defining your task, 
>or "
> +                        + "redeclare your ivy:settings in this classloader", 
>getLocation());
> +            }
> +        } else {
> +            antIvyEngine = IvyAntSettings.getDefaultInstance(this);
> +        }
> +        Ivy ivy = ((IvyAntSettings) 
>antIvyEngine).getConfiguredIvyInstance(this);
> +        AntMessageLogger.register(this, ivy);
> +        return ivy;
> +    }
> +
> +    protected Collection getCollection() {
> +        if (!getAllowedLogOptions().contains(log)) {
> +            throw new BuildException("invalid option for 'log': " + log
> +                    + ". Available options are " + getAllowedLogOptions());
> +        }
> +
> +        ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "", "");
> +        DefaultModuleDescriptor md = 
>DefaultModuleDescriptor.newBasicInstance(mrid, null);
> +
> +        Iterator itDeps = dependencies.iterator();
> +        while (itDeps.hasNext()) {
> +            IvyDependency dep = (IvyDependency) itDeps.next();
> +            DependencyDescriptor dd = dep.asDependencyDescriptor(md, 
>"default");
> +            md.addDependency(dd);
> +        }
> +
> +        Ivy ivy = getIvyInstance();
> +
> +        ResolveOptions options = new ResolveOptions();
> +        options.setConfs(new String[] {"default"});
> +        options.setDate(IvyTask.getPubDate(pubdate, null));
> +        options.setUseCacheOnly(useCacheOnly);
> +        options.setRefresh(refresh);
> +        options.setTransitive(transitive);
> +        options.setResolveMode(resolveMode);
> +        options.setResolveId(resolveId);
> +
> +        ResolveReport report;
> +        try {
> +            report = ivy.resolve(md, options);
> +        } catch (ParseException e) {
> +            throw new BuildException(e);
> +        } catch (IOException e) {
> +            throw new BuildException(e);
> +        }
> +
> +        List/* <> */resources = new ArrayList();
> +
> +        if (report.hasError()) {
> +            throw new BuildException("resolve failed - see output for 
>details");
> +        } else {
> +            Filter artifactTypeFilter = 
>FilterHelper.getArtifactTypeFilter(type);
> +
> +            ConfigurationResolveReport configurationReport = report
> +                    .getConfigurationReport("default");
> +            Set revisions = configurationReport.getModuleRevisionIds();
> +            for (Iterator it = revisions.iterator(); it.hasNext();) {
> +                ModuleRevisionId revId = (ModuleRevisionId) it.next();
> +                ArtifactDownloadReport[] aReports = 
>configurationReport.getDownloadReports(revId);
> +                for (int i = 0; i < aReports.length; i++) {
> +                    if (artifactTypeFilter.accept(aReports[i].getArtifact())) 
>{
> +                        resources.add(new 
>FileResource(aReports[i].getLocalFile()));
> +                    }
> +                }
> +            }
> +        }
> +
> +        return resources;
> +    }
> +
> +}
> 
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyTask.java Wed Oct 27 
>15:57:36 2010
> @@ -186,7 +186,7 @@ public abstract class IvyTask extends Ta
> 
>     private static final DateFormat DATE_FORMAT = new 
>SimpleDateFormat("yyyyMMddHHmmss");
> 
> -    protected Date getPubDate(String date, Date def) {
> +    protected static Date getPubDate(String date, Date def) {
>         if (date != null) {
>             if ("now".equals(date.toLowerCase(Locale.US))) {
>                 return new Date();
> 
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/antlib.xml
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/antlib.xml?rev=1028013&r1=1028012&r2=1028013&view=diff
>
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/antlib.xml (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/antlib.xml Wed Oct 27 
>15:57:36 2010
> @@ -18,7 +18,8 @@
>    under the License.    
> -->
> <antlib xmlns:current="ant:current">
> -    <typedef name="settings" classname="org.apache.ivy.ant.IvyAntSettings"/>
> +    <typedef name="settings" classname="org.apache.ivy.ant.IvyAntSettings"/>
> +    <typedef name="resources" classname="org.apache.ivy.ant.IvyResources"/>
>     <taskdef name="configure" classname="org.apache.ivy.ant.IvyConfigure"/>
>     <taskdef name="resolve" classname="org.apache.ivy.ant.IvyResolve"/>
>     <taskdef name="retrieve" classname="org.apache.ivy.ant.IvyRetrieve"/>
> 
> Added: ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResourcesTest.java
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResourcesTest.java?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResourcesTest.java 
>(added)
> +++ ant/ivy/core/trunk/test/java/org/apache/ivy/ant/IvyResourcesTest.java Wed 
>Oct 27 15:57:36 2010
> @@ -0,0 +1,207 @@
> +/*
> + *  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.ant;
> +
> +import java.io.File;
> +
> +import junit.framework.TestCase;
> +
> +import org.apache.ivy.Ivy;
> +import org.apache.ivy.TestHelper;
> +import org.apache.ivy.core.module.id.ModuleRevisionId;
> +import org.apache.tools.ant.BuildException;
> +import org.apache.tools.ant.DefaultLogger;
> +import org.apache.tools.ant.Project;
> +import org.apache.tools.ant.taskdefs.Delete;
> +
> +public class IvyResourcesTest extends TestCase {
> +
> +    private File cache;
> +
> +    private IvyResources resources;
> +
> +    protected void setUp() throws Exception {
> +        createCache();
> +        Project project = new Project();
> +        DefaultLogger logger = new DefaultLogger();
> +        logger.setOutputPrintStream(System.out);
> +        logger.setErrorPrintStream(System.err);
> +        logger.setMessageOutputLevel(Project.MSG_INFO);
> +        project.addBuildListener(logger);
> +        project.setProperty("ivy.settings.file", 
>"test/repositories/ivysettings.xml");
> +        project.setProperty("ivy.cache.dir", cache.getAbsolutePath());
> +
> +        resources = new IvyResources();
> +        resources.setProject(project);
> +    }
> +
> +    private void createCache() {
> +        cache = new File("build/cache");
> +        cache.mkdirs();
> +    }
> +
> +    protected void tearDown() throws Exception {
> +        cleanCache();
> +    }
> +
> +    private void cleanCache() {
> +        Delete del = new Delete();
> +        del.setProject(new Project());
> +        del.setDir(cache);
> +        del.execute();
> +    }
> +
> +    private File getIvyFileInCache(String organisation, String module, String 
>revision) {
> +        ModuleRevisionId id = ModuleRevisionId.newInstance(organisation, 
>module, revision);
> +        return TestHelper.getRepositoryCacheManager(getIvy(), 
>id).getIvyFileInCache(id);
> +    }
> +
> +    private File getArchiveFileInCache(String organisation, String module, 
>String revision,
> +            String artifact, String type, String ext) {
> +        return TestHelper.getArchiveFileInCache(getIvy(), organisation, 
>module, revision, artifact,
> +            type, ext);
> +    }
> +
> +    private Ivy getIvy() {
> +        return resources.getIvyInstance();
> +    }
> +
> +    public void testSimple() throws Exception {
> +        IvyDependency dependency = new IvyDependency();
> +        dependency.setOrg("org1");
> +        dependency.setName("mod1.2");
> +        dependency.setRev("2.0");
> +        resources.addDependency(dependency);
> +
> +        resources.iterator();
> +
> +        // dependencies
> +        assertTrue(getIvyFileInCache("org1", "mod1.2", "2.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
>"jar", "jar").exists());
> +    }
> +
> +    public void testMultiple() throws Exception {
> +        IvyDependency dependency = new IvyDependency();
> +        dependency.setOrg("org1");
> +        dependency.setName("mod1.2");
> +        dependency.setRev("2.0");
> +        resources.addDependency(dependency);
> +
> +        dependency = new IvyDependency();
> +        dependency.setOrg("org2");
> +        dependency.setName("mod2.3");
> +        dependency.setRev("0.7");
> +        resources.addDependency(dependency);
> +
> +        resources.iterator();
> +
> +        // dependencies
> +        assertTrue(getIvyFileInCache("org1", "mod1.2", "2.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.3", "0.7").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.3", "0.7", "mod2.3", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.1", "0.3").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21A", 
>"jar", "jar").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.3", "art21B", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org1", "mod1.1", "1.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org1", "mod1.2", "2.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
>"jar", "jar").exists());
> +    }
> +
> +    public void testMultipleWithConf() throws Exception {
> +        IvyDependency dependency = new IvyDependency();
> +        dependency.setOrg("org1");
> +        dependency.setName("mod1.2");
> +        dependency.setRev("2.0");
> +        resources.addDependency(dependency);
> +
> +        dependency = new IvyDependency();
> +        dependency.setOrg("org2");
> +        dependency.setName("mod2.2");
> +        dependency.setRev("0.10");
> +        dependency.setConf("A");
> +        resources.addDependency(dependency);
> +
> +        resources.iterator();
> +
> +        // dependencies
> +        assertTrue(getIvyFileInCache("org1", "mod1.2", "2.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.2", "0.10").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.2", "0.10", "mod2.2", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.1", "0.7").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.7", "mod2.1", 
>"jar", "jar").exists());
> +
> +        assertFalse(getIvyFileInCache("org1", "mod1.1", "1.0").exists());
> +        assertFalse(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", 
>"jar", "jar").exists());
> +    }
> +
> +    public void testMultipleWithConf2() throws Exception {
> +        IvyDependency dependency = new IvyDependency();
> +        dependency.setOrg("org1");
> +        dependency.setName("mod1.2");
> +        dependency.setRev("2.0");
> +        resources.addDependency(dependency);
> +
> +        dependency = new IvyDependency();
> +        dependency.setOrg("org2");
> +        dependency.setName("mod2.2");
> +        dependency.setRev("0.10");
> +        dependency.setConf("B");
> +        resources.addDependency(dependency);
> +
> +        resources.iterator();
> +
> +        // dependencies
> +        assertTrue(getIvyFileInCache("org1", "mod1.2", "2.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.0", "mod1.2", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.2", "0.10").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.2", "0.10", "mod2.2", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org2", "mod2.1", "0.7").exists());
> +        assertTrue(getArchiveFileInCache("org2", "mod2.1", "0.7", "mod2.1", 
>"jar", "jar").exists());
> +
> +        assertTrue(getIvyFileInCache("org1", "mod1.1", "1.0").exists());
> +        assertTrue(getArchiveFileInCache("org1", "mod1.1", "1.0", "mod1.1", 
>"jar", "jar").exists());
> +    }
> +
> +    public void testFail() throws Exception {
> +        IvyDependency dependency = new IvyDependency();
> +
> +        dependency.setOrg("org1");
> +        dependency.setName("noexisting");
> +        dependency.setRev("2.0");
> +
> +        resources.addDependency(dependency);
> +        try {
> +            resources.iterator();
> +            fail("A fail resolved should have raised a build exception");
> +        } catch (BuildException e) {
> +            // ok
> +        }
> +    }
> +
> +}
> 
> Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/ivys/ivy-0.7.xml
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/ivys/ivy-0.7.xml?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/ivys/ivy-0.7.xml 
(added)
> +++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/ivys/ivy-0.7.xml Wed Oct 
>27 15:57:36 2010
> @@ -0,0 +1,33 @@
> +<!--
> +   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.    
> +-->
> +<ivy-module version="1.0">
> +    <info organisation="org2"
> +           module="mod2.1"
> +           revision="0.7"
> +           status="integration"
> +           publication="20060801110000"
> +    />
> +    <configurations>
> +        <conf name="runtime"/>
> +        <conf name="compile" />
> +    </configurations>
> +    <dependencies>
> +        <dependency org="org1" name="mod1.1" rev="1.0" conf="compile->*"/>
> +    </dependencies>
> +</ivy-module>
> 
> Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/jars/mod2.1-0.7.jar
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/jars/mod2.1-0.7.jar?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/jars/mod2.1-0.7.jar 
>(added)
> +++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.1/jars/mod2.1-0.7.jar Wed 
>Oct 27 15:57:36 2010
> @@ -0,0 +1 @@
> + 
> 
> Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/ivys/ivy-0.10.xml
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/ivys/ivy-0.10.xml?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/ivys/ivy-0.10.xml 
>(added)
> +++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/ivys/ivy-0.10.xml Wed 
>Oct 27 15:57:36 2010
> @@ -0,0 +1,33 @@
> +<!--
> +   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.    
> +-->
> +<ivy-module version="1.0">
> +    <info organisation="org2"
> +           module="mod2.2"
> +           revision="0.10"
> +           status="integration"
> +           publication="20060801110000"
> +    />
> +    <configurations>
> +        <conf name="A" />
> +        <conf name="B" />
> +    </configurations>
> +    <dependencies>
> +        <dependency name="mod2.1" rev="0.7" conf="A->runtime;B->compile"/>
> +    </dependencies>
> +</ivy-module>
> 
> Added: ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/jars/mod2.2-0.10.jar
> URL: 
>http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/jars/mod2.2-0.10.jar?rev=1028013&view=auto
>
> ==============================================================================
> --- ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/jars/mod2.2-0.10.jar 
>(added)
> +++ ant/ivy/core/trunk/test/repositories/1/org2/mod2.2/jars/mod2.2-0.10.jar Wed 
>Oct 27 15:57:36 2010
> @@ -0,0 +1 @@
> + 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


      

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message