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 2010/10/27 17:58:36 UTC
svn commit: r1028014 - in /ant/ivy/core/trunk: doc/use/
src/java/org/apache/ivy/ant/
Author: hibou
Date: Wed Oct 27 15:58:35 2010
New Revision: 1028014
URL: http://svn.apache.org/viewvc?rev=1028014&view=rev
Log:
Fully implement the dependencies tag, still excluding everything about the master configuration
Added:
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConflict.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyArtifact.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyConf.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyExclude.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyInclude.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExclude.java
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyOverride.java
Modified:
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
Modified: ant/ivy/core/trunk/doc/use/resources.html
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/use/resources.html?rev=1028014&r1=1028013&r2=1028014&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/use/resources.html (original)
+++ ant/ivy/core/trunk/doc/use/resources.html Wed Oct 27 15:58:35 2010
@@ -30,6 +30,8 @@
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.
+There is one important difference: there is no master configuration to handle here. There is actually only one, the one on which the resolve will run.
+
<h1>Attributes</h1>
<table class="ant">
<thead>
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConflict.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConflict.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConflict.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyConflict.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,78 @@
+/*
+ * 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.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.conflict.ConflictManager;
+import org.apache.ivy.plugins.conflict.FixedConflictManager;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.xml.sax.Attributes;
+
+public class IvyConflict {
+
+ private String org;
+
+ private String module;
+
+ private String manager;
+
+ private String rev;
+
+ private String matcher;
+
+ public void setOrg(String org) {
+ this.org = org;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void setManager(String manager) {
+ this.manager = manager;
+ }
+
+ public void setRev(String rev) {
+ this.rev = rev;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ void addConflict(DefaultModuleDescriptor md, IvySettings settings) {
+ String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
+ String orgPattern = org == null ? PatternMatcher.ANY_EXPRESSION : org;
+ String modulePattern = module == null ? PatternMatcher.ANY_EXPRESSION : module;
+ ConflictManager cm = null;
+ if (rev != null) {
+ String[] revs = rev.split(",");
+ for (int i = 0; i < revs.length; i++) {
+ revs[i] = revs[i].trim();
+ }
+ cm = new FixedConflictManager(revs);
+ } else if (manager != null) {
+ cm = settings.getConflictManager(manager);
+ }
+ md.addConflictManager(new ModuleId(orgPattern, modulePattern),
+ settings.getMatcher(matcherName), cm);
+ }
+
+}
Modified: 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=1028014&r1=1028013&r2=1028014&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependency.java Wed Oct 27 15:58:35 2010
@@ -17,14 +17,29 @@
*/
package org.apache.ivy.ant;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
+import org.apache.ivy.core.module.descriptor.DefaultIncludeRule;
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.ivy.core.settings.IvySettings;
import org.apache.tools.ant.BuildException;
public class IvyDependency {
+ private List/* <IvyDependencyConf> */confs = new ArrayList();
+
+ private List/* <IvyDependencyArtifact> */artifacts = new ArrayList();
+
+ private List/* <IvyDependencyExclude> */excludes = new ArrayList();
+
+ private List/* <IvyDependencyIncludes> */includes = new ArrayList();
+
private String org;
private String name;
@@ -35,6 +50,30 @@ public class IvyDependency {
private String conf;
+ public IvyDependencyConf createConf() {
+ IvyDependencyConf c = new IvyDependencyConf();
+ confs.add(c);
+ return c;
+ }
+
+ public IvyDependencyArtifact createArtifact() {
+ IvyDependencyArtifact artifact = new IvyDependencyArtifact();
+ artifacts.add(artifact);
+ return artifact;
+ }
+
+ public IvyDependencyExclude createExclude() {
+ IvyDependencyExclude exclude = new IvyDependencyExclude();
+ excludes.add(exclude);
+ return exclude;
+ }
+
+ public IvyDependencyInclude createInclude() {
+ IvyDependencyInclude include = new IvyDependencyInclude();
+ includes.add(include);
+ return include;
+ }
+
public String getOrg() {
return org;
}
@@ -75,7 +114,7 @@ public class IvyDependency {
this.conf = conf;
}
- DependencyDescriptor asDependencyDescriptor(ModuleDescriptor md, String c) {
+ DependencyDescriptor asDependencyDescriptor(ModuleDescriptor md, String masterConf, IvySettings settings) {
if (org == null) {
throw new BuildException("'org' is required on ");
}
@@ -83,12 +122,40 @@ public class IvyDependency {
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);
+ DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid, false, false,
+ true);
if (conf != null) {
- dd.addDependencyConfiguration(c, conf);
+ dd.addDependencyConfiguration(masterConf, conf);
} else {
- dd.addDependencyConfiguration(c, "*");
+ dd.addDependencyConfiguration(masterConf, "*");
+ }
+
+ Iterator itConfs = confs.iterator();
+ while (itConfs.hasNext()) {
+ IvyDependencyConf c = (IvyDependencyConf) itConfs.next();
+ c.addConf(dd, masterConf);
+ }
+
+ Iterator itArtifacts = artifacts.iterator();
+ while (itArtifacts.hasNext()) {
+ IvyDependencyArtifact artifact = (IvyDependencyArtifact) itArtifacts.next();
+ artifact.addArtifact(dd, masterConf);
}
+
+ Iterator itExcludes = excludes.iterator();
+ while (itExcludes.hasNext()) {
+ IvyDependencyExclude exclude = (IvyDependencyExclude) itExcludes.next();
+ DefaultExcludeRule rule = exclude.asRule(settings);
+ dd.addExcludeRule(masterConf, rule);
+ }
+
+ Iterator itIncludes = includes.iterator();
+ while (itIncludes.hasNext()) {
+ IvyDependencyInclude include = (IvyDependencyInclude) itIncludes.next();
+ DefaultIncludeRule rule = include.asRule(settings);
+ dd.addIncludeRule(masterConf, rule);
+ }
+
return dd;
}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyArtifact.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyArtifact.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyArtifact.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyArtifact.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,67 @@
+/*
+ * 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.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.ivy.core.module.descriptor.DefaultDependencyArtifactDescriptor;
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+import org.apache.tools.ant.BuildException;
+
+public class IvyDependencyArtifact {
+
+ private String name;
+
+ private String type;
+
+ private String ext;
+
+ private String url;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ void addArtifact(DefaultDependencyDescriptor dd, String masterConf) {
+ String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
+ String extPattern = ext == null ? typePattern : ext;
+ URL u;
+ try {
+ u = url == null ? null : new URL(url);
+ } catch (MalformedURLException e) {
+ throw new BuildException("Malformed url in the artifact: " + e.getMessage());
+ }
+ DefaultDependencyArtifactDescriptor dad = new DefaultDependencyArtifactDescriptor(dd, name,
+ typePattern, extPattern, u, null);
+ dd.addDependencyArtifact(masterConf, dad);
+ }
+}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyConf.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyConf.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyConf.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyConf.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,64 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.ivy.core.module.descriptor.DefaultDependencyDescriptor;
+
+public class IvyDependencyConf {
+
+ private List/* <IvyDependencyConfMapped> */mappeds = new ArrayList();
+
+ public static class IvyDependencyConfMapped {
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ }
+
+ private String mapped;
+
+ public void setMapped(String mapped) {
+ this.mapped = mapped;
+ }
+
+ public IvyDependencyConfMapped createMapped() {
+ IvyDependencyConfMapped m = new IvyDependencyConfMapped();
+ mappeds.add(m);
+ return m;
+ }
+
+ void addConf(DefaultDependencyDescriptor dd, String masterConf) {
+ if (mapped != null) {
+ String[] mappeds = mapped.split(",");
+ for (int i = 0; i < mappeds.length; i++) {
+ dd.addDependencyConfiguration(masterConf, mappeds[i].trim());
+ }
+ }
+ Iterator itMappeds = mappeds.iterator();
+ while (itMappeds.hasNext()) {
+ IvyDependencyConfMapped m = (IvyDependencyConfMapped) itMappeds.next();
+ dd.addDependencyConfiguration(masterConf, m.name);
+ }
+ }
+}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyExclude.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyExclude.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyExclude.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyExclude.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.DefaultExcludeRule;
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+public class IvyDependencyExclude {
+
+ private String org;
+
+ private String module;
+
+ private String name;
+
+ private String type;
+
+ private String ext;
+
+ private String matcher;
+
+ public void setOrg(String org) {
+ this.org = org;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ DefaultExcludeRule asRule(IvySettings settings) {
+ String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
+ String orgPattern = org == null ? PatternMatcher.ANY_EXPRESSION : org;
+ String modulePattern = module == null ? PatternMatcher.ANY_EXPRESSION : module;
+ String namePattern = name == null ? PatternMatcher.ANY_EXPRESSION : name;
+ String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
+ String extPattern = ext == null ? typePattern : ext;
+ ArtifactId aid = new ArtifactId(new ModuleId(orgPattern, modulePattern), namePattern,
+ typePattern, extPattern);
+ return new DefaultExcludeRule(aid, settings.getMatcher(matcherName), null);
+ }
+}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyInclude.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyInclude.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyInclude.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyDependencyInclude.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.DefaultIncludeRule;
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+public class IvyDependencyInclude {
+
+ private String name;
+
+ private String type;
+
+ private String ext;
+
+ private String matcher;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ DefaultIncludeRule asRule(IvySettings settings) {
+ String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
+ String namePattern = name == null ? PatternMatcher.ANY_EXPRESSION : name;
+ String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
+ String extPattern = ext == null ? typePattern : ext;
+ ArtifactId aid = new ArtifactId(new ModuleId(PatternMatcher.ANY_EXPRESSION,
+ PatternMatcher.ANY_EXPRESSION), namePattern, typePattern, extPattern);
+ return new DefaultIncludeRule(aid, settings.getMatcher(matcherName), null);
+ }
+
+}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExclude.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExclude.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExclude.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyExclude.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.DefaultExcludeRule;
+import org.apache.ivy.core.module.id.ArtifactId;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+public class IvyExclude {
+
+ private String org;
+
+ private String module;
+
+ private String artifact;
+
+ private String type;
+
+ private String ext;
+
+ private String matcher;
+
+ public void setOrg(String org) {
+ this.org = org;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void setArtifact(String artifact) {
+ this.artifact = artifact;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setExt(String ext) {
+ this.ext = ext;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ DefaultExcludeRule asRule(IvySettings settings) {
+ String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
+ String orgPattern = org == null ? PatternMatcher.ANY_EXPRESSION : org;
+ String modulePattern = module == null ? PatternMatcher.ANY_EXPRESSION : module;
+ String artifactPattern = artifact == null ? PatternMatcher.ANY_EXPRESSION : artifact;
+ String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
+ String extPattern = ext == null ? typePattern : ext;
+ ArtifactId aid = new ArtifactId(new ModuleId(orgPattern, modulePattern), artifactPattern,
+ typePattern, extPattern);
+ return new DefaultExcludeRule(aid, settings.getMatcher(matcherName), null);
+ }
+}
Added: ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyOverride.java
URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyOverride.java?rev=1028014&view=auto
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyOverride.java (added)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyOverride.java Wed Oct 27 15:58:35 2010
@@ -0,0 +1,66 @@
+/*
+ * 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.DefaultModuleDescriptor;
+import org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator;
+import org.apache.ivy.core.module.id.ModuleId;
+import org.apache.ivy.core.settings.IvySettings;
+import org.apache.ivy.plugins.matcher.PatternMatcher;
+
+public class IvyOverride {
+
+ private String org;
+
+ private String module;
+
+ private String branch;
+
+ private String rev;
+
+ private String matcher;
+
+ public void setOrg(String org) {
+ this.org = org;
+ }
+
+ public void setModule(String module) {
+ this.module = module;
+ }
+
+ public void setBranch(String branch) {
+ this.branch = branch;
+ }
+
+ public void setRev(String rev) {
+ this.rev = rev;
+ }
+
+ public void setMatcher(String matcher) {
+ this.matcher = matcher;
+ }
+
+ void addOverride(DefaultModuleDescriptor md, IvySettings settings) {
+ String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
+ String orgPattern = org == null ? PatternMatcher.ANY_EXPRESSION : org;
+ String modulePattern = module == null ? PatternMatcher.ANY_EXPRESSION : module;
+ md.addDependencyDescriptorMediator(new ModuleId(orgPattern, modulePattern),
+ settings.getMatcher(matcherName), new OverrideDependencyDescriptorMediator(branch, rev));
+ }
+
+}
Modified: 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=1028014&r1=1028013&r2=1028014&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/IvyResources.java Wed Oct 27 15:58:35 2010
@@ -28,6 +28,7 @@ import java.util.Set;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.LogOptions;
+import org.apache.ivy.core.module.descriptor.DefaultExcludeRule;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
@@ -46,6 +47,10 @@ public class IvyResources extends BaseRe
private List/* <IvyDependency> */dependencies = new ArrayList();
+ private List/* <IvyExclude> */excludes = new ArrayList();
+
+ private List/* <IvyConflict> */conflicts = new ArrayList();
+
private String type = null;
private String pubdate = null;
@@ -64,6 +69,24 @@ public class IvyResources extends BaseRe
private Reference antIvyEngineRef;
+ public IvyDependency createDependency() {
+ IvyDependency dep = new IvyDependency();
+ dependencies.add(dep);
+ return dep;
+ }
+
+ public IvyExclude createExclude() {
+ IvyExclude ex = new IvyExclude();
+ excludes.add(ex);
+ return ex;
+ }
+
+ public IvyConflict createConflict() {
+ IvyConflict c = new IvyConflict();
+ conflicts.add(c);
+ return c;
+ }
+
public void setType(String type) {
this.type = type;
}
@@ -104,10 +127,6 @@ public class IvyResources extends BaseRe
antIvyEngineRef = ref;
}
- public void addDependency(IvyDependency dependency) {
- dependencies.add(dependency);
- }
-
public boolean isFilesystemOnly() {
return true;
}
@@ -145,17 +164,30 @@ public class IvyResources extends BaseRe
+ ". Available options are " + getAllowedLogOptions());
}
+ Ivy ivy = getIvyInstance();
+
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");
+ DependencyDescriptor dd = dep.asDependencyDescriptor(md, "default", ivy.getSettings());
md.addDependency(dd);
}
- Ivy ivy = getIvyInstance();
+ Iterator itExcludes = excludes.iterator();
+ while (itExcludes.hasNext()) {
+ IvyExclude exclude = (IvyExclude) itExcludes.next();
+ DefaultExcludeRule rule = exclude.asRule(ivy.getSettings());
+ md.addExcludeRule(rule);
+ }
+
+ Iterator itConflicts = conflicts.iterator();
+ while (itConflicts.hasNext()) {
+ IvyConflict conflict = (IvyConflict) itConflicts.next();
+ conflict.addConflict(md, ivy.getSettings());
+ }
ResolveOptions options = new ResolveOptions();
options.setConfs(new String[] {"default"});