You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/20 09:27:32 UTC
[maven-ant-plugin] 23/48: [MANT-32] java.lang.ClassCastException
when packaging jeuclid-3.0.1
This is an automated email from the ASF dual-hosted git repository.
hboutemy pushed a commit to annotated tag maven-ant-plugin-2.1
in repository https://gitbox.apache.org/repos/asf/maven-ant-plugin.git
commit 969914360b4d5fef9dfb936930d3f1f0b3378a16
Author: Benjamin Bentmann <be...@apache.org>
AuthorDate: Fri Mar 21 21:28:30 2008 +0000
[MANT-32] java.lang.ClassCastException when packaging jeuclid-3.0.1
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-ant-plugin@639856 13f79535-47bb-0310-9956-ffa450edef68
---
.../maven/plugin/ant/AntBuildWriterUtil.java | 49 +++++++++++++++++++---
.../maven/plugin/ant/AntBuildWriterUtilTest.java | 18 ++++++++
.../unit/ant-compiler-config-test/pom.xml | 3 ++
3 files changed, 64 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
index a214eb8..df4b066 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
@@ -1257,16 +1257,53 @@ public class AntBuildWriterUtil
String lastNodeName = null;
for ( int i = 0; i < childs.getLength(); i++ )
{
- if ( childs.item( i ).getNodeType() == Node.ELEMENT_NODE )
+ Node child = childs.item( i );
+ if ( child.getNodeType() == Node.ELEMENT_NODE )
{
- if ( i != 0 )
- {
- isList = isList || ( childs.item( i ).getNodeName().equals( lastNodeName ) );
- }
- lastNodeName = childs.item( i ).getNodeName();
+ isList = isList || ( child.getNodeName().equals( lastNodeName ) );
+ lastNodeName = child.getNodeName();
}
}
+ if ( StringUtils.isNotEmpty( lastNodeName ) )
+ {
+ isList = isList || lastNodeName.equals( getSingularForm( node.getNodeName() ) );
+ }
return isList;
}
+
+ /**
+ * Gets the singular form of the specified (English) plural form. For example:
+ *
+ * <pre>
+ * properties -> property
+ * branches -> branch
+ * reports -> report
+ * </pre>
+ *
+ * @param pluralForm The plural form for which to derive the singular form, may be <code>null</code>.
+ * @return The corresponding singular form or an empty string if the input string was not recognized as a plural
+ * form.
+ */
+ static String getSingularForm( String pluralForm )
+ {
+ String singularForm = "";
+ if ( StringUtils.isNotEmpty( pluralForm ) )
+ {
+ if ( pluralForm.endsWith( "ies" ) )
+ {
+ singularForm = pluralForm.substring( 0, pluralForm.length() - 3 ) + 'y';
+ }
+ else if ( pluralForm.endsWith( "ches" ) )
+ {
+ singularForm = pluralForm.substring( 0, pluralForm.length() - 2 );
+ }
+ else if ( pluralForm.endsWith( "s" ) && pluralForm.length() > 1 )
+ {
+ singularForm = pluralForm.substring( 0, pluralForm.length() - 1 );
+ }
+ }
+ return singularForm;
+ }
+
}
diff --git a/src/test/java/org/apache/maven/plugin/ant/AntBuildWriterUtilTest.java b/src/test/java/org/apache/maven/plugin/ant/AntBuildWriterUtilTest.java
index 3bcc628..8f5663f 100644
--- a/src/test/java/org/apache/maven/plugin/ant/AntBuildWriterUtilTest.java
+++ b/src/test/java/org/apache/maven/plugin/ant/AntBuildWriterUtilTest.java
@@ -105,6 +105,8 @@ public class AntBuildWriterUtilTest
assertNotNull( AntBuildWriterUtil.getMavenCompilerPluginOptions( project, "includes", null ) );
assertEquals( AntBuildWriterUtil.getMavenCompilerPluginOptions( project, "includes", null ).length, 2 );
+ assertNotNull( AntBuildWriterUtil.getMavenCompilerPluginOptions( project, "excludes", null ) );
+ assertEquals( AntBuildWriterUtil.getMavenCompilerPluginOptions( project, "excludes", null ).length, 1 );
maven.stop();
}
@@ -164,4 +166,20 @@ public class AntBuildWriterUtilTest
maven.stop();
}
+
+ /**
+ * Test method for {@link AntBuildWriterUtil#getSingularForm(String)}.
+ *
+ * @throws Exception
+ */
+ public static void testGetSingularForm()
+ throws Exception
+ {
+ assertEquals( "property", AntBuildWriterUtil.getSingularForm( "properties" ) );
+ assertEquals( "branch", AntBuildWriterUtil.getSingularForm( "branches" ) );
+ assertEquals( "report", AntBuildWriterUtil.getSingularForm( "reports" ) );
+ assertEquals( "", AntBuildWriterUtil.getSingularForm( "singular" ) );
+ assertEquals( "", AntBuildWriterUtil.getSingularForm( null ) );
+ }
+
}
diff --git a/src/test/resources/unit/ant-compiler-config-test/pom.xml b/src/test/resources/unit/ant-compiler-config-test/pom.xml
index d9a4a99..1cdc148 100644
--- a/src/test/resources/unit/ant-compiler-config-test/pom.xml
+++ b/src/test/resources/unit/ant-compiler-config-test/pom.xml
@@ -45,6 +45,9 @@ under the License.
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<debug>true</debug>
+ <excludes>
+ <exclude>**/reversemapping/Main.java</exclude>
+ </excludes>
<includes>
<include>**/*.java</include>
<include>**/*.jad</include>
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.