Modified: incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java Mon Dec 19 11:17:36 2011 @@ -28,11 +28,9 @@ import npanday.executable.ExecutableRequ import npanday.executable.ExecutionException; import npanday.executable.NetExecutable; import npanday.executable.NetExecutableFactory; -import npanday.vendor.IllegalStateException; +import npanday.registry.RepositoryRegistry; +import npanday.vendor.SettingsUtil; import npanday.vendor.StateMachineProcessor; -import npanday.vendor.Vendor; -import npanday.vendor.VendorInfo; -import npanday.vendor.VendorRequirement; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -48,6 +46,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import static com.google.common.base.Strings.isNullOrEmpty; + /** * Runs NUnit tests * @@ -56,9 +56,17 @@ import java.util.Set; * @phase test * @description Runs NUnit tests */ -public class TesterMojo -extends AbstractMojo +public class TesterMojo extends AbstractMojo { + /** + * @parameter expression="${npanday.settings}" default-value="${user.home}/.m2" + */ + private String settingsPath; + + /** + * @component + */ + private RepositoryRegistry repositoryRegistry; /** * The maven project. @@ -162,9 +170,22 @@ extends AbstractMojo private StateMachineProcessor processor; /** + * The Vendor for the Compiler. Not case or white-space sensitive. + * + * @parameter expression="${vendor}" + */ + private String vendor; + + /** + * @parameter expression = "${vendorVersion}" + */ + private String vendorVersion; + + /** * Specify the name of the NUnit command to be run, from within the <i>nunitHome</i>/bin directory. * * @parameter + * @deprecated since 1.5.0-incubating */ private String nunitCommand; @@ -185,44 +206,13 @@ extends AbstractMojo return (nunitHome != null) ? new File(nunitHome, "bin") : null; } - private String getExecutableNameFor( VendorInfo vendorInfo ) - { - String executableName = nunitCommand; - - // default the executable name if not explicitly specified - if ( executableName == null ) - { - // nunit-console-x86 is included since 2.4.2 (August 2007, http://www.nunit.org/index.php?p=releaseNotes&r=2.4.3) - executableName = "nunit-console" + (forceX86 ? "-x86" : ""); - if ( vendorInfo != null ) - { - Vendor vendor = vendorInfo.getVendor(); - String frameworkVersion = vendorInfo.getFrameworkVersion(); - if ( "MONO".equals( vendor.getVendorName() ) ) - { - // Note: Mono 2.10 adds support for .NET framework 4.0 and packages nunit-console.exe, - // with shell scripts for both nunit-console and nunit-console2 so no need to - // use nunit-console2 in that case - if ( frameworkVersion == null || (!frameworkVersion.startsWith( "1.1" ) && !frameworkVersion.startsWith( "4.0" ) ) ) - { - executableName = "nunit-console2"; - } - } - } - - } - - return executableName; - } - - private List<String> getCommandsFor( VendorInfo vendorInfo ) + private List<String> getCommandsFor( ) { - Vendor vendor = vendorInfo.getVendor(); String finalName = project.getBuild().getFinalName(); List<String> commands = new ArrayList<String>(); - if ( testAssemblyPath.startsWith( "/" ) )// nunit-console thinks *nix file format /home/user/ is an option - // due to / and fails. + if ( testAssemblyPath.startsWith( "/" ) ) // nunit-console thinks *nix file format /home/user/ is an option + // due to / and fails. { testAssemblyPath = "/" + testAssemblyPath; } @@ -241,12 +231,6 @@ extends AbstractMojo } String switchChar = "/"; - - String vendorName = vendor.getVendorName(); - if ( vendor != null && "MONO".equals( vendorName ) ) - { - switchChar = "-"; - } commands.add( switchChar + "xml:" + nUnitXmlFilePath.getAbsolutePath() ); commands.add( switchChar + "output:" + nUnitResultOutputPath.getAbsolutePath() ); @@ -259,7 +243,7 @@ extends AbstractMojo commands.add( switchChar + "xmlConsole" ); } - // Not supported on NUnit < 2.5 - see NPANDAY-332 + // Not supported on NUnit < 2.5 - see NPANDAY-332 // String frameworkVersion = vendorInfo.getFrameworkVersion(); // getLog().debug( "NPANDAY-1100-012: Framework version:" + frameworkVersion ); // if (!"MONO".equals( vendorName ) && (frameworkVersion != null && frameworkVersion.length() > 0 )) { @@ -278,6 +262,8 @@ extends AbstractMojo getLog().warn( "NPANDAY-1100-000: Unit tests have been disabled." ); return; } + + SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry, settingsPath ); String testFileName = ""; @@ -387,46 +373,32 @@ extends AbstractMojo FileUtils.mkdir( reportsDirectory ); - VendorRequirement vendorRequirement = new VendorRequirement( (Vendor)null, null, executionFrameworkVersion ); - getLog().debug( "NPANDAY-1100-014.2: Vendor info:" + vendorRequirement ); - VendorInfo vendorInfo; - try - { - vendorInfo = processor.process( vendorRequirement ); - } - catch ( IllegalStateException e ) - { - throw new MojoExecutionException( "NPANDAY-1100-016: Error on determining the vendor info", e ); - } - catch ( PlatformUnsupportedException e ) - { - throw new MojoExecutionException( "NPANDAY-1100-017: Error on determining the vendor info", e ); - } - //List<String> commands = getCommandsFor( vendorInfo.getVendor() ); - getLog().debug( "NPANDAY-1100-014.3: Vendor info:" + vendorInfo ); - List<String> commands = getCommandsFor( vendorInfo ); - getLog().debug( "NPANDAY-1100-008: " + commands.toString() ); + + List<String> commands = getCommandsFor( ); // pretty print nunit logs getLog().info( System.getProperty( "line.separator" ) ); - String executableName = getExecutableNameFor( vendorInfo ); + String profile = "NUNIT" + (forceX86 ? "-x86" : ""); File executableHome = getExecutableHome(); try { try { - Vendor vendor = vendorInfo.getVendor(); - String vendorName = vendor.getVendorName(); - NetExecutable executable = netExecutableFactory.getNetExecutableFor( - new ExecutableRequirement( vendorName, null, executionFrameworkVersion, executableName), commands, executableHome ); + new ExecutableRequirement( vendor, vendorVersion, executionFrameworkVersion, profile), commands, executableHome ); executable.execute(); } catch (PlatformUnsupportedException pue) { + if (isNullOrEmpty(nunitCommand)) + { + throw new MojoExecutionException( "NPANDAY-1100-008: Unsupported Platform.", pue ); + } + + // TODO: This should rather be done through a configurable local executable-plugins.xml; then remove nunitcommand getLog().debug( "NPANDAY-1100-008: Platform unsupported, is your npanday-settings.xml configured correctly?", pue ); CommandExecutor commandExecutor = CommandExecutor.Factory.createDefaultCommmandExecutor(); commandExecutor.setLogger( new org.codehaus.plexus.logging.AbstractLogger( 0, "nunit-logger" ) @@ -464,7 +436,7 @@ extends AbstractMojo } } ); - String executablePath = (executableHome != null) ? new File(executableHome, executableName).toString() : executableName; + String executablePath = (executableHome != null) ? new File(executableHome, nunitCommand).toString() : nunitCommand; commandExecutor.executeCommand( executablePath, commands ); } }
Modified: incubator/npanday/trunk/plugins/maven-test-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-test-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-test-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml (original) +++ incubator/npanday/trunk/plugins/maven-test-plugin/src/main/resources/META-INF/npanday/executable-plugins.xml Mon Dec 19 11:17:36 2011 @@ -17,16 +17,19 @@ specific language governing permissions under the License. --> <executablePlugins> + + <!-- native nunit runners --> <executablePlugin> - <identifier>nunit-console</identifier> + <identifier>NUNIT</identifier> <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> <vendor>MICROSOFT</vendor> <executable>nunit-console</executable> - <profile>nunit-console</profile> + <profile>NUNIT</profile> <frameworkVersions> <frameworkVersion>4.0</frameworkVersion> <frameworkVersion>3.5</frameworkVersion> <frameworkVersion>2.0.50727</frameworkVersion> + <frameworkVersion>1.1.4322</frameworkVersion> </frameworkVersions> <platforms> <platform> @@ -35,11 +38,11 @@ under the License. </platforms> </executablePlugin> <executablePlugin> - <identifier>nunit-console-x86</identifier> + <identifier>NUNIT-x86</identifier> <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> <vendor>MICROSOFT</vendor> <executable>nunit-console-x86</executable> - <profile>nunit-console-x86</profile> + <profile>NUNIT-x86</profile> <frameworkVersions> <frameworkVersion>4.0</frameworkVersion> <frameworkVersion>3.5</frameworkVersion> @@ -51,14 +54,45 @@ under the License. </platform> </platforms> </executablePlugin> + + + <!-- Mono-packaged NUNIT-runners --> <executablePlugin> - <identifier>nunit-console</identifier> + <identifier>NUNIT</identifier> <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> <vendor>MONO</vendor> <executable>nunit-console</executable> - <profile>nunit-console</profile> + <profile>NUNIT</profile> <frameworkVersions> <frameworkVersion>4.0</frameworkVersion> + <frameworkVersion>1.1.4322</frameworkVersion> + </frameworkVersions> + <platforms> + <platform> + <operatingSystem>Windows</operatingSystem> + </platform> + <platform> + <operatingSystem>Mac OS X</operatingSystem> + </platform> + <platform> + <operatingSystem>Linux</operatingSystem> + </platform> + <platform> + <operatingSystem>Solaris</operatingSystem> + </platform> + <platform> + <operatingSystem>FreeBSD</operatingSystem> + </platform> + </platforms> + </executablePlugin> + <executablePlugin> + <identifier>NUNIT</identifier> + <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> + <vendor>MONO</vendor> + <!-- until MONO < 2.10, nunit for CLR 2.0 dll's are run though nunit-console2 --> + <executable>nunit-console2</executable> + <profile>NUNIT</profile> + <frameworkVersions> <frameworkVersion>3.5</frameworkVersion> <frameworkVersion>2.0.50727</frameworkVersion> </frameworkVersions> @@ -80,12 +114,15 @@ under the License. </platform> </platforms> </executablePlugin> + + <executablePlugin> - <identifier>nunit-console2</identifier> + <identifier>NUNIT-x86</identifier> <pluginClass>npanday.executable.impl.DefaultNetExecutable</pluginClass> <vendor>MONO</vendor> - <executable>nunit-console2</executable> - <profile>nunit-console2</profile> + <!-- this does not work with the packaged MONO nunit runners! --> + <executable>nunit-console-x86</executable> + <profile>NUNIT-x86</profile> <frameworkVersions> <frameworkVersion>4.0</frameworkVersion> <frameworkVersion>3.5</frameworkVersion> @@ -95,7 +132,7 @@ under the License. <platform> <operatingSystem>Windows</operatingSystem> </platform> - <platform> + <platform> <operatingSystem>Mac OS X</operatingSystem> </platform> <platform> Modified: incubator/npanday/trunk/plugins/maven-wsdl-plugin/src/main/java/npanday/plugin/wsdl/WsdlGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-wsdl-plugin/src/main/java/npanday/plugin/wsdl/WsdlGeneratorMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-wsdl-plugin/src/main/java/npanday/plugin/wsdl/WsdlGeneratorMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-wsdl-plugin/src/main/java/npanday/plugin/wsdl/WsdlGeneratorMojo.java Mon Dec 19 11:17:36 2011 @@ -22,7 +22,6 @@ import npanday.PlatformUnsupportedExcept import npanday.executable.ExecutableRequirement; import npanday.executable.ExecutionException; import npanday.registry.RepositoryRegistry; -import npanday.vendor.SettingsException; import npanday.vendor.SettingsUtil; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -221,17 +220,7 @@ public class WsdlGeneratorMojo public void execute() throws MojoExecutionException { - - - try - { - SettingsUtil.getOrPopulateSettingsRepository( repositoryRegistry, settingsPath ); - } - catch ( SettingsException e ) - { - throw new MojoExecutionException( - "NPANDAY-1300-006 Failed to create the repository registry for this plugin", e ); - } + SettingsUtil.applyCustomSettings(getLog(), repositoryRegistry, settingsPath ); FileUtils.mkdir( outputDirectory ); Modified: incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XmlToXsdGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XmlToXsdGeneratorMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XmlToXsdGeneratorMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XmlToXsdGeneratorMojo.java Mon Dec 19 11:17:36 2011 @@ -22,6 +22,7 @@ import npanday.PlatformUnsupportedExcept import npanday.executable.ExecutableRequirement; import npanday.executable.ExecutionException; import npanday.registry.RepositoryRegistry; +import npanday.vendor.SettingsUtil; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; @@ -42,6 +43,10 @@ import java.util.List; public class XmlToXsdGeneratorMojo extends AbstractMojo { + /** + * @parameter expression="${npanday.settings}" default-value="${user.home}/.m2" + */ + private String settingsPath; /** * The directory to place the generated binding classes. @@ -105,6 +110,8 @@ public class XmlToXsdGeneratorMojo public void execute() throws MojoExecutionException { + SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry, settingsPath ); + FileUtils.mkdir( outputDirectory ); try { Modified: incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XsdGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XsdGeneratorMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XsdGeneratorMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XsdGeneratorMojo.java Mon Dec 19 11:17:36 2011 @@ -22,7 +22,6 @@ import npanday.PlatformUnsupportedExcept import npanday.executable.ExecutableRequirement; import npanday.executable.ExecutionException; import npanday.registry.RepositoryRegistry; -import npanday.vendor.SettingsException; import npanday.vendor.SettingsUtil; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; @@ -173,16 +172,7 @@ public class XsdGeneratorMojo public void execute() throws MojoExecutionException { - - try - { - SettingsUtil.getOrPopulateSettingsRepository( repositoryRegistry, settingsPath ); - } - catch ( SettingsException e ) - { - throw new MojoExecutionException( - "NPANDAY-114-0035 Failed to create the repository registry for this plugin", e ); - } + SettingsUtil.applyCustomSettings(getLog(), repositoryRegistry, settingsPath ); FileUtils.mkdir( outputDirectory ); try Modified: incubator/npanday/trunk/plugins/maven-xsp-plugin/src/main/java/npanday/plugin/xsp/XspStarterMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-xsp-plugin/src/main/java/npanday/plugin/xsp/XspStarterMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/maven-xsp-plugin/src/main/java/npanday/plugin/xsp/XspStarterMojo.java (original) +++ incubator/npanday/trunk/plugins/maven-xsp-plugin/src/main/java/npanday/plugin/xsp/XspStarterMojo.java Mon Dec 19 11:17:36 2011 @@ -19,6 +19,8 @@ package npanday.plugin.xsp; import npanday.executable.ExecutableRequirement; +import npanday.registry.RepositoryRegistry; +import npanday.vendor.SettingsUtil; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.AbstractMojo; import npanday.PlatformUnsupportedException; @@ -39,6 +41,16 @@ public class XspStarterMojo extends AbstractMojo { /** + * @parameter expression="${npanday.settings}" default-value="${user.home}/.m2" + */ + private String settingsPath; + + /** + * @component + */ + private RepositoryRegistry repositoryRegistry; + + /** * The home directory of your .NET SDK. * * @parameter expression="${netHome}" @@ -57,6 +69,9 @@ public class XspStarterMojo public void execute() throws MojoExecutionException { + + SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry, settingsPath ); + try { final ExecutableRequirement executableRequirement = new ExecutableRequirement( Modified: incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java (original) +++ incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/src/main/java/NPanday/Plugin/Settings/SettingsGeneratorMojo.java Mon Dec 19 11:17:36 2011 @@ -21,21 +21,16 @@ import npanday.PathUtil; import npanday.plugin.FieldAnnotation; -import npanday.registry.NPandayRepositoryException; import npanday.registry.RepositoryRegistry; -import npanday.vendor.SettingsException; import npanday.vendor.SettingsUtil; -import npanday.vendor.SettingsRepository; import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -import javax.naming.OperationNotSupportedException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.File; @@ -167,6 +162,7 @@ public class SettingsGeneratorMojo if ( skip ) { + getLog().info( "NPANDAY-119-000: Excecution of generate-settings has been skipped." ); return false; } @@ -203,15 +199,6 @@ public class SettingsGeneratorMojo try { - SettingsUtil.populateSettingsRepository( repositoryRegistry, settingsPath ); - } - catch ( SettingsException e ) - { - throw new MojoExecutionException( "NPANDAY-112: Could not populate settings", e ); - } - - try - { // check if npanday-settings contains the framework DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); @@ -272,32 +259,6 @@ public class SettingsGeneratorMojo public void postExecute() throws MojoExecutionException, MojoFailureException { - // TODO: proper error handling - try - { - // TODO: let the registry be injected as @component - RepositoryRegistry repositoryRegistry = (RepositoryRegistry) container.lookup( RepositoryRegistry.ROLE ); - SettingsRepository settingsRepository = (SettingsRepository) repositoryRegistry.find( "npanday-settings" ); - if ( settingsRepository != null ) - { - settingsRepository.reloadAll(); - } - } - catch ( ComponentLookupException e ) - { - e.printStackTrace(); - } - catch ( IOException e ) - { - e.printStackTrace(); - } - catch( NPandayRepositoryException e ) - { - e.printStackTrace(); - } - catch ( OperationNotSupportedException e ) - { - e.printStackTrace(); - } + SettingsUtil.applyCustomSettings( getLog(), repositoryRegistry, settingsPath ); } } Modified: incubator/npanday/trunk/plugins/partcover-maven-plugin/src/main/java/npanday/plugin/partcover/AbstractPartCoverMojo.java URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/partcover-maven-plugin/src/main/java/npanday/plugin/partcover/AbstractPartCoverMojo.java?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/plugins/partcover-maven-plugin/src/main/java/npanday/plugin/partcover/AbstractPartCoverMojo.java (original) +++ incubator/npanday/trunk/plugins/partcover-maven-plugin/src/main/java/npanday/plugin/partcover/AbstractPartCoverMojo.java Mon Dec 19 11:17:36 2011 @@ -28,6 +28,7 @@ import org.apache.maven.plugin.AbstractM import java.io.IOException; +// TODO: should be refactored to use executable plugin !!!! public abstract class AbstractPartCoverMojo extends AbstractMojo { Modified: incubator/npanday/trunk/pom.xml URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/pom.xml?rev=1220688&r1=1220687&r2=1220688&view=diff ============================================================================== --- incubator/npanday/trunk/pom.xml (original) +++ incubator/npanday/trunk/pom.xml Mon Dec 19 11:17:36 2011 @@ -339,7 +339,7 @@ under the License. <artifactId>qdox</artifactId> <version>1.12</version> </dependency> - </dependencies> + </dependencies> <executions> <execution> <phase>process-classes</phase>
