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:38 UTC
[maven-ant-plugin] 29/48: [MANT-40] Use includes/excludes
configured for Surefire when running tests
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 ef4a0118560d602f856564480718e365e7312f8b
Author: Benjamin Bentmann <be...@apache.org>
AuthorDate: Sat Mar 22 13:12:36 2008 +0000
[MANT-40] Use includes/excludes configured for Surefire when running tests
git-svn-id: https://svn.apache.org/repos/asf/maven/plugins/trunk/maven-ant-plugin@639990 13f79535-47bb-0310-9956-ffa450edef68
---
src/it/test-custom-selector-it/goals.txt | 2 +
src/it/test-custom-selector-it/pom.xml | 79 ++++++++++++++++++++++
.../src/test/java/it/BadTest.java | 37 ++++++++++
.../src/test/java/it/BrokenTest.java | 37 ++++++++++
.../src/test/java/it/ExcludedTestCase.java | 37 ++++++++++
.../src/test/java/it/GoodTest.java | 37 ++++++++++
.../src/test/java/it/TestExcluded.java | 37 ++++++++++
src/it/test-custom-selector-it/verify.bsh | 23 +++++++
src/it/test-default-selector-it/goals.txt | 2 +
src/it/test-default-selector-it/pom.xml | 66 ++++++++++++++++++
.../src/test/java/it/AbstractTest.java | 37 ++++++++++
.../src/test/java/it/GoodTest.java | 37 ++++++++++
.../src/test/java/it/GoodTestCase.java | 37 ++++++++++
.../src/test/java/it/TestGood.java | 37 ++++++++++
src/it/test-default-selector-it/verify.bsh | 41 +++++++++++
.../apache/maven/plugin/ant/AntBuildWriter.java | 57 ++++++++++++++--
.../maven/plugin/ant/AntBuildWriterUtil.java | 45 ++++++++++++
17 files changed, 641 insertions(+), 7 deletions(-)
diff --git a/src/it/test-custom-selector-it/goals.txt b/src/it/test-custom-selector-it/goals.txt
new file mode 100644
index 0000000..16cd63b
--- /dev/null
+++ b/src/it/test-custom-selector-it/goals.txt
@@ -0,0 +1,2 @@
+ant:ant
+initialize
diff --git a/src/it/test-custom-selector-it/pom.xml b/src/it/test-custom-selector-it/pom.xml
new file mode 100644
index 0000000..3597c78
--- /dev/null
+++ b/src/it/test-custom-selector-it/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.maven-ant-plugin.it</groupId>
+ <artifactId>test-custom-selector-it</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ant-plugin</artifactId>
+ <version>@pom.version@</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <ant dir="${basedir}" antfile="${basedir}/build.xml" target="package" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.2</version>
+ <configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Bad*.java</exclude>
+ <exclude>**/Broken*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <build.compiler>extJavac</build.compiler>
+ </properties>
+
+</project>
diff --git a/src/it/test-custom-selector-it/src/test/java/it/BadTest.java b/src/it/test-custom-selector-it/src/test/java/it/BadTest.java
new file mode 100644
index 0000000..447024f
--- /dev/null
+++ b/src/it/test-custom-selector-it/src/test/java/it/BadTest.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class BadTest
+ extends TestCase
+{
+
+ public void testFail()
+ throws Exception
+ {
+ fail( "This test should have been excluded." );
+ }
+
+}
diff --git a/src/it/test-custom-selector-it/src/test/java/it/BrokenTest.java b/src/it/test-custom-selector-it/src/test/java/it/BrokenTest.java
new file mode 100644
index 0000000..297ac41
--- /dev/null
+++ b/src/it/test-custom-selector-it/src/test/java/it/BrokenTest.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class BrokenTest
+ extends TestCase
+{
+
+ public void testFail()
+ throws Exception
+ {
+ fail( "This test should have been excluded." );
+ }
+
+}
diff --git a/src/it/test-custom-selector-it/src/test/java/it/ExcludedTestCase.java b/src/it/test-custom-selector-it/src/test/java/it/ExcludedTestCase.java
new file mode 100644
index 0000000..458f0a3
--- /dev/null
+++ b/src/it/test-custom-selector-it/src/test/java/it/ExcludedTestCase.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class ExcludedTestCase
+ extends TestCase
+{
+
+ public void testFail()
+ throws Exception
+ {
+ fail( "This test should have been excluded." );
+ }
+
+}
diff --git a/src/it/test-custom-selector-it/src/test/java/it/GoodTest.java b/src/it/test-custom-selector-it/src/test/java/it/GoodTest.java
new file mode 100644
index 0000000..c6f6032
--- /dev/null
+++ b/src/it/test-custom-selector-it/src/test/java/it/GoodTest.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class GoodTest
+ extends TestCase
+{
+
+ public void testPass()
+ throws Exception
+ {
+ assertTrue( true );
+ }
+
+}
diff --git a/src/it/test-custom-selector-it/src/test/java/it/TestExcluded.java b/src/it/test-custom-selector-it/src/test/java/it/TestExcluded.java
new file mode 100644
index 0000000..8567c6d
--- /dev/null
+++ b/src/it/test-custom-selector-it/src/test/java/it/TestExcluded.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class TestExcluded
+ extends TestCase
+{
+
+ public void testFail()
+ throws Exception
+ {
+ fail( "This test should have been excluded." );
+ }
+
+}
diff --git a/src/it/test-custom-selector-it/verify.bsh b/src/it/test-custom-selector-it/verify.bsh
new file mode 100644
index 0000000..c993878
--- /dev/null
+++ b/src/it/test-custom-selector-it/verify.bsh
@@ -0,0 +1,23 @@
+import java.io.*;
+import java.util.*;
+
+try
+{
+ File reportDir = new File( basedir, "target/test-reports" );
+
+ {
+ File file = new File( reportDir, "TEST-it.GoodTest.xml" );
+ if ( !file.isFile() )
+ {
+ System.err.println( "Report file does not exist: " + file );
+ return false;
+ }
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
diff --git a/src/it/test-default-selector-it/goals.txt b/src/it/test-default-selector-it/goals.txt
new file mode 100644
index 0000000..16cd63b
--- /dev/null
+++ b/src/it/test-default-selector-it/goals.txt
@@ -0,0 +1,2 @@
+ant:ant
+initialize
diff --git a/src/it/test-default-selector-it/pom.xml b/src/it/test-default-selector-it/pom.xml
new file mode 100644
index 0000000..30b173c
--- /dev/null
+++ b/src/it/test-default-selector-it/pom.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.maven-ant-plugin.it</groupId>
+ <artifactId>test-default-selector-it</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <build>
+ <finalName>${project.artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ant-plugin</artifactId>
+ <version>@pom.version@</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <configuration>
+ <tasks>
+ <ant dir="${basedir}" antfile="${basedir}/build.xml" target="package" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-junit</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ <!-- use default values for surefire includes/excludes -->
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <properties>
+ <build.compiler>extJavac</build.compiler>
+ </properties>
+
+</project>
diff --git a/src/it/test-default-selector-it/src/test/java/it/AbstractTest.java b/src/it/test-default-selector-it/src/test/java/it/AbstractTest.java
new file mode 100644
index 0000000..710a0c9
--- /dev/null
+++ b/src/it/test-default-selector-it/src/test/java/it/AbstractTest.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public abstract class AbstractTest
+ extends TestCase
+{
+
+ public void testFail()
+ throws Exception
+ {
+ fail( "This test should have been excluded." );
+ }
+
+}
diff --git a/src/it/test-default-selector-it/src/test/java/it/GoodTest.java b/src/it/test-default-selector-it/src/test/java/it/GoodTest.java
new file mode 100644
index 0000000..c6f6032
--- /dev/null
+++ b/src/it/test-default-selector-it/src/test/java/it/GoodTest.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class GoodTest
+ extends TestCase
+{
+
+ public void testPass()
+ throws Exception
+ {
+ assertTrue( true );
+ }
+
+}
diff --git a/src/it/test-default-selector-it/src/test/java/it/GoodTestCase.java b/src/it/test-default-selector-it/src/test/java/it/GoodTestCase.java
new file mode 100644
index 0000000..eeacb43
--- /dev/null
+++ b/src/it/test-default-selector-it/src/test/java/it/GoodTestCase.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class GoodTestCase
+ extends TestCase
+{
+
+ public void testPass()
+ throws Exception
+ {
+ assertTrue( true );
+ }
+
+}
diff --git a/src/it/test-default-selector-it/src/test/java/it/TestGood.java b/src/it/test-default-selector-it/src/test/java/it/TestGood.java
new file mode 100644
index 0000000..eb61ac5
--- /dev/null
+++ b/src/it/test-default-selector-it/src/test/java/it/TestGood.java
@@ -0,0 +1,37 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Id$
+ */
+public class TestGood
+ extends TestCase
+{
+
+ public void testPass()
+ throws Exception
+ {
+ assertTrue( true );
+ }
+
+}
diff --git a/src/it/test-default-selector-it/verify.bsh b/src/it/test-default-selector-it/verify.bsh
new file mode 100644
index 0000000..1422080
--- /dev/null
+++ b/src/it/test-default-selector-it/verify.bsh
@@ -0,0 +1,41 @@
+import java.io.*;
+import java.util.*;
+
+try
+{
+ File reportDir = new File( basedir, "target/test-reports" );
+
+ {
+ File file = new File( reportDir, "TEST-it.GoodTest.xml" );
+ if ( !file.isFile() )
+ {
+ System.err.println( "Report file does not exist: " + file );
+ return false;
+ }
+ }
+
+ {
+ File file = new File( reportDir, "TEST-it.GoodTestCase.xml" );
+ if ( !file.isFile() )
+ {
+ System.err.println( "Report file does not exist: " + file );
+ return false;
+ }
+ }
+
+ {
+ File file = new File( reportDir, "TEST-it.TestGood.xml" );
+ if ( !file.isFile() )
+ {
+ System.err.println( "Report file does not exist: " + file );
+ return false;
+ }
+ }
+}
+catch( Throwable t )
+{
+ t.printStackTrace();
+ return false;
+}
+
+return true;
diff --git a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
index 561f7a0..ac9cab6 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriter.java
@@ -23,6 +23,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
@@ -744,6 +746,7 @@ public class AntBuildWriter
* @param testCompileSourceRoots
*/
private void writeTestTargets( XMLWriter writer, List testCompileSourceRoots )
+ throws IOException
{
AntBuildWriterUtil.writeCommentText( writer, "Run all tests", 1 );
@@ -812,18 +815,27 @@ public class AntBuildWriter
writer.startElement( "batchtest" );
writer.addAttribute( "todir", "${maven.test.reports}" );
+ List includes =
+ getSelectorList( AntBuildWriterUtil.getMavenSurefirePluginOptions( project, "includes", null ) );
+ if ( includes == null || includes.isEmpty() )
+ {
+ includes = Arrays.asList( new String[] { "**/Test*.java", "**/*Test.java", "**/*TestCase.java" } );
+ }
+
+ List excludes =
+ getSelectorList( AntBuildWriterUtil.getMavenSurefirePluginOptions( project, "excludes", null ) );
+ if ( excludes == null || excludes.isEmpty() )
+ {
+ excludes = Arrays.asList( new String[] { "**/*Abstract*Test.java" } );
+ }
+
String[] compileSourceRoots = (String[]) testCompileSourceRoots.toArray( new String[0] );
for ( int i = 0; i < compileSourceRoots.length; i++ )
{
writer.startElement( "fileset" );
writer.addAttribute( "dir", "${maven.build.testDir." + i + "}" );
- /* TODO: need to get these from the test plugin somehow?
- UnitTest unitTest = project.getBuild().getUnitTest();
- writeIncludesExcludes( writer, unitTest.getIncludes(), unitTest.getExcludes() );
- // TODO: m1 allows additional test exclusions via maven.ant.excludeTests
- */
- AntBuildWriterUtil.writeIncludesExcludes( writer, Collections.singletonList( "**/*Test.java" ),
- Collections.singletonList( "**/*Abstract*Test.java" ) );
+ // TODO: m1 allows additional test exclusions via maven.ant.excludeTests
+ AntBuildWriterUtil.writeIncludesExcludes( writer, includes, excludes );
writer.endElement(); // fileset
}
writer.endElement(); // batchtest
@@ -1265,4 +1277,35 @@ public class AntBuildWriter
return sb.toString();
}
+
+ /**
+ * Flattens the specified file selector options into a simple string list. For instance, the input
+ *
+ * <pre>
+ * [ {include="*Test.java"}, {include="*TestCase.java"} ]
+ * </pre>
+ *
+ * is converted to
+ *
+ * <pre>
+ * [ "*Test.java", "*TestCase.java" ]
+ * </pre>
+ *
+ * @param options The file selector options to flatten, may be <code>null</code>.
+ * @return The string list, might be empty but never <code>null</code>.
+ */
+ private static List getSelectorList( Map[] options )
+ {
+ List list = new ArrayList();
+ if ( options != null && options.length > 0 )
+ {
+ for ( int i = 0; i < options.length; i++ )
+ {
+ Map option = options[i];
+ list.addAll( option.values() );
+ }
+ }
+ return list;
+ }
+
}
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 df4b066..bb5a2b0 100644
--- a/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
+++ b/src/main/java/org/apache/maven/plugin/ant/AntBuildWriterUtil.java
@@ -779,6 +779,51 @@ public class AntBuildWriterUtil
}
/**
+ * Return the <code>optionName</code> value defined in a project for the "maven-surefire-plugin" plugin.
+ *
+ * @param project not null
+ * @param optionName the option name wanted
+ * @param defaultValue a default value
+ * @return the value for the option name or the default value. Could be null if not found.
+ * @throws IOException if any
+ */
+ public static String getMavenSurefirePluginBasicOption( MavenProject project, String optionName, String defaultValue )
+ throws IOException
+ {
+ return getMavenPluginBasicOption( project, "maven-surefire-plugin", optionName, defaultValue );
+ }
+
+ /**
+ * Return the map of <code>optionName</code> value defined in a project for the "maven-surefire-plugin" plugin.
+ *
+ * @param project not null
+ * @param optionName the option name wanted
+ * @param defaultValue a default value
+ * @return the map for the option name or the default value. Could be null if not found.
+ * @throws IOException if any
+ */
+ public static Map getMavenSurefirePluginOption( MavenProject project, String optionName, String defaultValue )
+ throws IOException
+ {
+ return getMavenPluginOption( project, "maven-surefire-plugin", optionName, defaultValue );
+ }
+
+ /**
+ * Return an array of map of <code>optionName</code> value defined in a project for the "maven-surefire-plugin" plugin.
+ *
+ * @param project not null
+ * @param optionName the option name wanted
+ * @param defaultValue a default value
+ * @return the array of option name or the default value. Could be null if not found.
+ * @throws IOException if any
+ */
+ public static Map[] getMavenSurefirePluginOptions( MavenProject project, String optionName, String defaultValue )
+ throws IOException
+ {
+ return getMavenPluginOptions( project, "maven-surefire-plugin", optionName, defaultValue );
+ }
+
+ /**
* Return the <code>optionName</code> value defined in a project for the "maven-javadoc-plugin" plugin.
*
* @param project not null
--
To stop receiving notification emails like this one, please contact
"commits@maven.apache.org" <co...@maven.apache.org>.