Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Developers List »

Re: svn commit: r636252 - in /ant/ivy/core/trunk: ./ src/java/org/apache/ivy/core/module/descriptor/ src/java/org/apache/ivy/plugins/parser/m2/ src/java/org/apache/ivy/plugins/parser/xml/ test/java/org/apache/ivy/plugins/parser/m2/ test/java/org/apac

Gilles Scokart

2008-03-16


Author LoginPost Reply
The unit test PomModuleDescriptorWriterTest should be adpated.
http://vmgump.apache.org/gump/public/ivy/ivy-tests/gump_file/TEST-org.apache.ivy.plugins.parser.m2.PomModuleDescriptorWriterTest.xml.html

Gilles

On 12/03/2008, xavier@(protected):
> Author: xavier
> Date: Wed Mar 12 01:44:56 2008
> New Revision: 636252
>
> URL: http://svn.apache.org/viewvc?rev=636252&view=rev
> Log:
> - IMPROVEMENT: Parse description information in ivy files (IVY-766)
> - IMPROVEMENT: Parse description and home page from poms (IVY-767)
>
> Modified:
>   ant/ivy/core/trunk/CHANGES.txt
>   ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
>   ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
>   ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
>   ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
>   ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
>   ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
>   ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
>   ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
>
> Modified: ant/ivy/core/trunk/CHANGES.txt
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/CHANGES.txt (original)
> +++ ant/ivy/core/trunk/CHANGES.txt Wed Mar 12 01:44:56 2008
> @@(protected) @@
>
>  - IMPROVEMENT: Make Ivy standalone runnable with no required dependencies (IVY-757)
>  - IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
> +- IMPROVEMENT: Parse description information in ivy files (IVY-766)
> +- IMPROVEMENT: Parse description and home page from poms (IVY-767)
>
>  - FIX: Ivy reports a conflict when the same file is supposed to be retrieved at the same location twice (or more) (IVY-743)
>  - FIX: StackOverflowError when configuration extends itself (IVY-696)
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>       }
>       nmd.licenses.addAll(Arrays.asList(md.getLicenses()));
>       nmd.homePage = md.getHomePage();
> +     nmd.description = md.getDescription();
>       nmd.lastModified = md.getLastModified();
>       nmd.extraAttributesNamespaces = md.getExtraAttributesNamespaces();
>       nmd.extraInfo = md.getExtraInfo();
> @@(protected) @@
>
>    private String homePage;
>
> +   private String description = "";
> +
>    private long lastModified = 0;
>
>    private Namespace namespace;
> @@(protected) @@
>
>    public void setHomePage(String homePage) {
>       this.homePage = homePage;
> +   }
> +
> +   public String getDescription() {
> +     return description;
> +   }
> +
> +   public void setDescription(String description) {
> +     this.description = description;
>    }
>
>    public long getLastModified() {
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>    License[] getLicenses();
>
>    String getHomePage();
> +
> +   String getDescription();
>
>    long getLastModified();
>
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorBuilder.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>       mrid = ModuleRevisionId.newInstance(groupId, artifactId, version);
>       ivyModuleDescriptor.setModuleRevisionId(mrid);
>     }
> +
> +   public void setHomePage(String homePage) {
> +     ivyModuleDescriptor.setHomePage(homePage);
> +   }
> +
> +   public void setDescription(String description) {
> +     ivyModuleDescriptor.setDescription(description);
> +   }
>
>
>    public void addArtifact(String artifactId, String packaging) {
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParser.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>         String artifactId = domReader.getArtifactId();
>         String version = domReader.getVersion();
>         mdBuilder.setModuleRevId(groupId , artifactId , version);
> +
> +        mdBuilder.setHomePage(domReader.getHomePage());
> +        mdBuilder.setDescription(domReader.getDescription());
>
>         ModuleRevisionId relocation = domReader.getRelocation();
>
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>    private static final String GROUP_ID = "groupId";
>    private static final String ARTIFACT_ID = "artifactId";
>    private static final String VERSION = "version";
> +   private static final String DESCRIPTION = "description";
> +   private static final String HOMEPAGE = "url";
>    private static final String PARENT = "parent";
>    private static final String SCOPE = "scope";
>    private static final String CLASSIFIER = "classifier";
> @@(protected) @@
>         val = "jar";
>       }
>       return val;
> +   }
> +
> +   public String getHomePage() {
> +     String val = getFirstChildText(projectElement , HOMEPAGE);
> +     if (val == null) {
> +        val = "";
> +     }
> +     return val;
> +   }
> +
> +   public String getDescription() {
> +     String val = getFirstChildText(projectElement , DESCRIPTION);
> +     if (val == null) {
> +        val = "";
> +     }
> +     return val.trim();
>    }
>
>
>
> Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (original)
> +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>         try {
>            if (state == DESCRIPTION) {
>               //make sure we don't interpret any tag while in description tag
> +             buffer.append("<" + qName + ">");
>               return;
>            } else if ("ivy-module".equals(qName)) {
>               ivyModuleStarted(attributes);
> @@(protected) @@
>            } else if (state == INFO && "description".equals(qName)) {
>               getMd().setHomePage(ivy.substitute(attributes.getValue("homepage")));
>               state = DESCRIPTION;
> +             buffer = new StringBuffer();
>            } else if (state == INFO && "ivyauthor".equals(qName)) {
>               // nothing to do, we don't store this
>            } else if (state == INFO && "repository".equals(qName)) {
> @@(protected) @@
>         } else if (state == INFO && "info".equals(qName)) {
>            state = NONE;
>         } else if (state == DESCRIPTION && "description".equals(qName)) {
> +           getMd().setDescription(buffer == null ? "" : buffer.toString().trim());
> +           buffer = null;
>            state = INFO;
>         } else if (state == EXTRA_INFO) {
>            getMd().addExtraInfo(qName, buffer == null ? "" : buffer.toString());
>            buffer = null;
>            state = INFO;
> +        } else if (state == DESCRIPTION) {
> +           if (buffer.toString().endsWith("<" + qName + ">")) {
> +             buffer.deleteCharAt(buffer.length() - 1);
> +             buffer.append("/>");
> +           } else {
> +             buffer.append("</" + qName + ">");
> +           }
>         }
>       }
>
>
> Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java (original)
> +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/m2/PomModuleDescriptorParserTest.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>       assertEquals(0, dds.length);
>    }
>
> +   public void testHomeAndDescription() throws Exception {
> +     ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
> +        settings, getClass().getResource("mule-1.3.3.pom"), false);
> +     assertNotNull(md);
> +
> +     assertEquals(ModuleRevisionId.newInstance("org.mule", "mule", "1.3.3"), md
> +           .getModuleRevisionId());
> +
> +     assertEquals("http://mule.mulesource.org", md.getHomePage());
> +     assertEquals("Mule is a simple yet robust and highly scalable Integration and ESB services "
> +               + "framework. It is designed\n     as a light-weight, event-driven component "
> +               + "technology that handles communication with disparate systems\n     "
> +               + "transparently providing a simple component interface.",
> +               md.getDescription().replace("\n\r", "\n").replace("\r", "\n"));
> +   }
> +
>
>    public void testDependencyManagment() throws ParseException, IOException {
>       ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(
>
> Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java
> URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java?rev=636252&r1=636251&r2=636252&view=diff
> ==============================================================================
> --- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java (original)
> +++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParserTest.java Wed Mar 12 01:44:56 2008
> @@(protected) @@
>       assertEquals("http://www.my.org/mymodule/mylicense.html", licenses[0].getUrl());
>
>       assertEquals("http://www.my.org/mymodule/", md.getHomePage());
> +     assertEquals("This module is <b>great</b> !<br/>\n\t"
> +               + "You can use it especially with myconf1 and myconf2, "
> +               + "and myconf4 is not too bad too.",
> +               md.getDescription().replace("\n\r", "\n").replace("\r", "\n"));
>
>       assertEquals(1, md.getExtraInfo().size());
>       assertEquals("56576", md.getExtraInfo().get("e:someExtra"));
>
>
>


--
Gilles Scokart

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@(protected)
For additional commands, e-mail: dev-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.