Permalink
Browse files

Fix for FLEXMOJOS-415

  • Loading branch information...
1 parent 00ab4e6 commit 54e91ddceb835921d0538d7eedb10842977f166a @velo velo committed Aug 1, 2011
@@ -8,7 +8,7 @@
import static org.sonatype.flexmojos.matcher.artifact.ArtifactMatcher.classifier;
import static org.sonatype.flexmojos.matcher.artifact.ArtifactMatcher.groupId;
import static org.sonatype.flexmojos.matcher.artifact.ArtifactMatcher.type;
-import static org.sonatype.flexmojos.plugin.common.FlexExtension.SWC;
+import static org.sonatype.flexmojos.plugin.common.FlexExtension.*;
import static org.sonatype.flexmojos.util.PathUtil.path;
import java.io.File;
@@ -869,8 +869,15 @@ protected String toClass( String filename )
List<String> fileIncludes = new ArrayList<String>();
for ( String classInclude : classesIncludes )
{
- fileIncludes.add( classInclude.replace( '.', File.separatorChar ) + ".as" );
- fileIncludes.add( classInclude.replace( '.', File.separatorChar ) + ".mxml" );
+ if ( classInclude.endsWith( MXML ) || classInclude.endsWith( AS ) )
+ {
+ fileIncludes.add( "**/" + classInclude );
+ }
+ else
+ {
+ fileIncludes.add( "**/" + classInclude.replace( '.', File.separatorChar ) + ".as" );
+ fileIncludes.add( "**/" + classInclude.replace( '.', File.separatorChar ) + ".mxml" );
+ }
}
return fileIncludes;
}
@@ -24,6 +24,8 @@
String APK = "apk";
+ String AS = "as";
+
String BAR = "bar";
String CSS = "css";
@@ -36,6 +38,8 @@
String IPA = "ipa";
+ String MXML = "mxml";
+
String POM = "pom";
String RB_SWC = "rb.swc";
@@ -1,5 +1,6 @@
package org.sonatype.flexmojos.plugin.test;
+import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.Matchers.nullValue;
@@ -19,6 +20,7 @@
import static org.sonatype.flexmojos.plugin.common.FlexScopes.RSL;
import static org.sonatype.flexmojos.plugin.common.FlexScopes.TEST;
import static org.sonatype.flexmojos.util.PathUtil.file;
+import static org.sonatype.flexmojos.util.PathUtil.files;
import java.io.File;
import java.io.FileInputStream;
@@ -38,10 +40,10 @@
import org.apache.commons.io.IOUtils;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.FileSet;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
import org.sonatype.flexmojos.compiler.IRuntimeSharedLibraryPath;
import org.sonatype.flexmojos.compiler.MxmlcConfigurationHolder;
import org.sonatype.flexmojos.compiler.command.Result;
@@ -122,14 +124,14 @@
*
* @parameter
*/
- private String[] excludeTestFiles;
+ private List<String> excludeTestFiles;
/**
* File to be tested. If not defined assumes Test*.as and *Test.as
*
* @parameter
*/
- private String[] includeTestFiles;
+ private List<String> includeTestFiles;
/**
* @readonly
@@ -630,26 +632,14 @@ else if ( !testRunnerTemplate.exists() )
protected List<String> getTestClasses()
{
- getLog().debug( "Scanning for tests at " + testSourceDirectory + " for " + Arrays.toString( includeTestFiles )
- + " but " + Arrays.toString( excludeTestFiles ) );
+ getLog().debug( "Scanning for tests at " + testCompileSourceRoots + " for " + includeTestFiles + " but "
+ + excludeTestFiles );
- DirectoryScanner scanner = new DirectoryScanner();
- scanner.setIncludes( includeTestFiles );
- scanner.setExcludes( excludeTestFiles );
- scanner.addDefaultExcludes();
- scanner.setBasedir( testSourceDirectory );
- scanner.scan();
+ FileSet fs = new FileSet();
+ fs.setIncludes( includeTestFiles );
+ fs.setExcludes( excludeTestFiles );
+ List<String> testClasses = filterClasses( asList( fs ), files( testCompileSourceRoots ) );
- getLog().debug( "Test files: " + Arrays.toString( scanner.getIncludedFiles() ) );
- List<String> testClasses = new ArrayList<String>();
- for ( String testClass : scanner.getIncludedFiles() )
- {
- int endPoint = testClass.lastIndexOf( '.' );
- testClass = testClass.substring( 0, endPoint ); // remove extension
- testClass = testClass.replace( '/', '.' ); // Unix OS
- testClass = testClass.replace( '\\', '.' ); // Windows OS
- testClasses.add( testClass );
- }
getLog().debug( "Test classes: " + testClasses );
return testClasses;
}
@@ -658,26 +648,13 @@ protected void initializeIncludes()
{
if ( test != null )
{
- includeTestFiles = new String[] { test };
+ includeTestFiles = asList( test );
excludeTestFiles = null;
}
- if ( includeTestFiles == null || includeTestFiles.length == 0 )
- {
- includeTestFiles = new String[] { "**/Test*.as", "**/*Test.as", "**/Test*.mxml", "**/*Test.mxml" };
- }
- else
+ if ( includeTestFiles == null || includeTestFiles.isEmpty() )
{
- for ( int i = 0; i < includeTestFiles.length; i++ )
- {
- String pattern = includeTestFiles[i];
-
- if ( !pattern.endsWith( ".as" ) && !pattern.endsWith( ".mxml" ) )
- {
- pattern = pattern + ".as";
- }
- includeTestFiles[i] = "**/" + pattern;
- }
+ includeTestFiles = asList( "**/Test*.as", "**/*Test.as", "**/Test*.mxml", "**/*Test.mxml" );
}
}

0 comments on commit 54e91dd

Please sign in to comment.