IMPROVE: ivy now supports ${pom.version} in poms (IVY-174)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Xavier Hanin 2006-02-15 02:53:29 +00:00
parent d7d9cf45fa
commit cbffbc5882
4 changed files with 31 additions and 1 deletions

View File

@ -1,3 +1,4 @@
- IMPROVE: ivy now supports ${pom.version} in poms (IVY-174)
- IMPROVE: adds the possibility to disable concistency check (IVY-163)
- IMPROVE: add possibility to choose matcher on include exclude and conflict manager rules in ivy files, and on resolver per module in ivyconf (IVY-161)
- IMPROVE: add regexp management in the install ant task (IVY-154)

View File

@ -37,6 +37,7 @@ import fr.jayasoft.ivy.matcher.ExactPatternMatcher;
import fr.jayasoft.ivy.matcher.PatternMatcher;
import fr.jayasoft.ivy.parser.AbstractModuleDescriptorParser;
import fr.jayasoft.ivy.repository.Resource;
import fr.jayasoft.ivy.util.IvyPatternHelper;
import fr.jayasoft.ivy.util.Message;
import fr.jayasoft.ivy.util.XMLHelper;
import fr.jayasoft.ivy.xml.XmlModuleDescriptorWriter;
@ -72,6 +73,7 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
private boolean _optional = false;
private List _exclusions = new ArrayList();
private DefaultDependencyDescriptor _dd;
private Map _properties = new HashMap();
public Parser(Ivy ivy, Resource res) {
_ivy = ivy;
@ -100,6 +102,7 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
public void endElement(String uri, String localName, String qName) throws SAXException {
if ((_organisation != null && _module != null && _revision != null) && _md.getModuleRevisionId() == null) {
ModuleRevisionId mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
_properties.put("pom.version", _revision);
_md.setModuleRevisionId(mrid);
_md.addArtifact("master", new DefaultArtifact(mrid, getDefaultPubDate(),_module, "jar", "jar"));
_organisation = null;
@ -152,7 +155,7 @@ public class PomModuleDescriptorParser extends AbstractModuleDescriptorParser {
}
public void characters(char[] ch, int start, int length) throws SAXException {
String txt = new String(ch, start, length).trim();
String txt = IvyPatternHelper.substituteVariables(new String(ch, start, length).trim(), _properties);
String context = getContext();
if (_md.getModuleRevisionId() == null || context.startsWith("project/dependencies/dependency")) {
if (_organisation == null && context.endsWith("groupId")) {

View File

@ -57,6 +57,18 @@ public class PomModuleDescriptorParserTest extends AbstractModuleDescriptorParse
assertEquals(ModuleRevisionId.newInstance("commons-logging", "commons-logging", "1.0.4"), dds[0].getDependencyRevisionId());
}
public void testProperties() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new Ivy(), getClass().getResource("test-properties.pom"), false);
assertNotNull(md);
assertEquals(ModuleRevisionId.newInstance("drools", "drools-smf", "2.0-beta-18"), md.getModuleRevisionId());
DependencyDescriptor[] dds = md.getDependencies();
assertNotNull(dds);
assertEquals(1, dds.length);
assertEquals(ModuleRevisionId.newInstance("drools", "drools-core", "2.0-beta-18"), dds[0].getDependencyRevisionId());
}
public void testReal() throws Exception {
ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(new Ivy(), getClass().getResource("commons-lang-1.0.pom"), false);
assertNotNull(md);

View File

@ -0,0 +1,14 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>drools</groupId>
<artifactId>drools-smf</artifactId>
<name>Drools :: Semantics Module Framework</name>
<version>2.0-beta-18</version>
<dependencies>
<dependency>
<groupId>drools</groupId>
<artifactId>drools-core</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</project>