Author: sisbell Date: Thu Dec 14 14:45:24 2006 New Revision: 487379 URL: http://svn.apache.org/viewvc?view=rev&rev=487379 Log: Added support for signing assemblies.
Added: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java (with props) incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java (with props) incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java (with props) incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/AssemblyInfo.cs Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/ExecutableConfig.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerConfig.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerContext.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/DefaultCompiler.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/CompilerContextImpl.java incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/AssemblyInfoGeneratorMojo.java incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/CompilerMojo.java incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestCompilerMojo.java Added: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java?view=auto&rev=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java (added) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java Thu Dec 14 14:45:24 2006 @@ -0,0 +1,9 @@ +package org.apache.maven.dotnet.assembler; + +import java.io.IOException; +import java.io.InputStream; + +public interface AssemblyInfoUnmarshaller +{ + AssemblyInfo unmarshall( InputStream inputStream) throws IOException; +} Propchange: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java?view=auto&rev=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java (added) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java Thu Dec 14 14:45:24 2006 @@ -0,0 +1,52 @@ +package org.apache.maven.dotnet.assembler.impl; + +import org.apache.maven.dotnet.assembler.AssemblyInfoUnmarshaller; +import org.apache.maven.dotnet.assembler.AssemblyInfo; + +import java.io.InputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.BufferedReader; + +public class DefaultAssemblyInfoUnmarshaller implements AssemblyInfoUnmarshaller { + public AssemblyInfo unmarshall(InputStream inputStream) throws IOException { + AssemblyInfo assemblyInfo = new AssemblyInfo(); + BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = reader.readLine()) != null) { + String[] tokens = line.split("[:]"); + + if (tokens.length == 2) { + String[] assemblyTokens = tokens[1].split("[(]"); + String name = assemblyTokens[0].trim(); + String value = assemblyTokens[1].trim().split("[\"]")[1].trim(); + setAssemblyInfo(assemblyInfo, name, value); + } + } + return assemblyInfo; + } + + private void setAssemblyInfo(AssemblyInfo assemblyInfo, String name, String value) throws IOException { + if (!name.startsWith("Assembly")) + throw new IOException("NMAVEN-xxx-xxx: Invalid assembly info parameter: Name = " + name + ", Value = " + value); + if(name.equals("AssemblyDescription")) { + assemblyInfo.setDescription(value); + } else if(name.equals("AssemblyTitle")) { + assemblyInfo.setTitle(value); + } else if(name.equals("AssemblyCompany")) { + assemblyInfo.setCompany(value); + } else if(name.equals("AssemblyProduct")) { + assemblyInfo.setProduct(value); + } else if(name.equals("AssemblyCopyright")) { + assemblyInfo.setCopyright(value); + } else if(name.equals("AssemblyTrademark")) { + assemblyInfo.setTrademark(value); + } else if(name.equals("AssemblyCulture")) { + assemblyInfo.setCulture(value); + } else if(name.equals("AssemblyVersion")) { + assemblyInfo.setVersion(value); + } else if(name.equals("AssemblyConfiguration")) { + assemblyInfo.setConfiguration(value); + } + } +} Propchange: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java?view=auto&rev=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java (added) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java Thu Dec 14 14:45:24 2006 @@ -0,0 +1,41 @@ +package org.apache.maven.dotnet.assembler.impl; + +import junit.framework.TestCase; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.File; + +import org.apache.maven.dotnet.assembler.AssemblyInfo; + +public class DefaultAssemblyInfoUnmarshallerTest + extends TestCase +{ + private static String basedir = System.getProperty( "basedir" ); + + public void testUnmarshall() + { + FileInputStream fis = null; + try + { + fis = new FileInputStream( + basedir + "/src/test/resources/AssemblyInfo.cs" ); + } + catch ( FileNotFoundException e ) + { + fail("Could not find test file"); + } + + DefaultAssemblyInfoUnmarshaller um = new DefaultAssemblyInfoUnmarshaller(); + try + { + AssemblyInfo assemblyInfo = um.unmarshall( fis ); + assertEquals( "Incorrect Assembly Version", "1.0.0", assemblyInfo.getVersion()); + } + catch ( IOException e ) + { + fail("Problem iwht reading the assembly info input"); + } + } +} Propchange: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/AssemblyInfo.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/AssemblyInfo.cs?view=auto&rev=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/AssemblyInfo.cs (added) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/resources/AssemblyInfo.cs Thu Dec 14 14:45:24 2006 @@ -0,0 +1,11 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("it0002")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("-it0002")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyVersion("1.0.0")] +[assembly: AssemblyConfiguration("")] \ No newline at end of file Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/ExecutableConfig.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/ExecutableConfig.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/ExecutableConfig.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/ExecutableConfig.java Thu Dec 14 14:45:24 2006 @@ -20,6 +20,7 @@ import org.apache.maven.dotnet.executable.compiler.CompilerConfig; import org.apache.maven.dotnet.executable.compiler.ArtifactType; +import org.apache.maven.dotnet.executable.compiler.KeyInfo; import java.util.List; import java.io.File; @@ -80,6 +81,8 @@ { return new CompilerConfig() { + private KeyInfo keyInfo; + private List<String> commands; private String executionPath; @@ -138,6 +141,15 @@ public void setLocalRepository( File localRepository ) { this.localRepository = localRepository; + } + + public KeyInfo getKeyInfo() + { + return keyInfo; + } + + public void setKeyInfo(KeyInfo keyInfo) { + this.keyInfo = keyInfo; } }; } Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerConfig.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerConfig.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerConfig.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerConfig.java Thu Dec 14 14:45:24 2006 @@ -45,6 +45,8 @@ * @return true if the compiler plugin should compile the test classes, otherwise returns false. */ boolean isTestCompile(); + + KeyInfo getKeyInfo(); /** * Returns local repository @@ -74,5 +76,6 @@ */ void setLocalRepository( File localRepository ); + void setKeyInfo(KeyInfo keyInfo); } Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerContext.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerContext.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerContext.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/CompilerContext.java Thu Dec 14 14:45:24 2006 @@ -81,6 +81,8 @@ */ List<Artifact> getDirectModuleDependencies(); + KeyInfo getKeyInfo(); + /** * Returns a list of library (dll) dependencies of the class files. * Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/DefaultCompiler.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/DefaultCompiler.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/DefaultCompiler.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/compiler/impl/DefaultCompiler.java Thu Dec 14 14:45:24 2006 @@ -140,6 +140,11 @@ commands.add( "/nologo" ); } + if(compilerContext.getKeyInfo().getKeyFileUri() != null) + { + commands.add("/keyfile:" + compilerContext.getKeyInfo().getKeyFileUri()); + } + if ( config.getCommands() != null ) { commands.addAll( config.getCommands() ); Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/CompilerContextImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/CompilerContextImpl.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/CompilerContextImpl.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-executable/src/main/java/org/apache/maven/dotnet/executable/impl/CompilerContextImpl.java Thu Dec 14 14:45:24 2006 @@ -32,6 +32,7 @@ import org.apache.maven.dotnet.registry.Repository; import org.apache.maven.dotnet.registry.RepositoryRegistry; import org.apache.maven.dotnet.RepositoryNotFoundException; +import org.apache.maven.dotnet.vendor.Vendor; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; @@ -133,6 +134,15 @@ artifacts.add( project.getArtifact() ); } return artifacts; + } + + public KeyInfo getKeyInfo() { + if((compilerRequirement.getVendor().equals( Vendor.MICROSOFT ) + && compilerRequirement.getFrameworkVersion().equals("1.1.4322")) || config.getKeyInfo() == null) { + return KeyInfo.Factory.createDefaultKeyInfo(); + } else { + return config.getKeyInfo(); + } } public List<Artifact> getLibraryDependencies() Modified: incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/AssemblyInfoGeneratorMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/AssemblyInfoGeneratorMojo.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/AssemblyInfoGeneratorMojo.java (original) +++ incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/AssemblyInfoGeneratorMojo.java Thu Dec 14 14:45:24 2006 @@ -39,7 +39,9 @@ * @goal generate-assembly-info * @phase generate-sources */ -public class AssemblyInfoGeneratorMojo extends AbstractMojo { +public class AssemblyInfoGeneratorMojo + extends AbstractMojo +{ /** * The maven project. @@ -76,37 +78,53 @@ * * @throws MojoExecutionException */ - public void execute() throws MojoExecutionException { - if (project.getArtifact().getType().equals("module")) { + public void execute() + throws MojoExecutionException + { + if ( project.getArtifact().getType().equals( "module" ) ) + { return; } - File srcFile = new File(sourceDirectory); - if (srcFile.exists()) { - try { - List files = FileUtils.getFiles(srcFile, "**/AssemblyInfo.*", null); - if (files.size() != 0) { - getLog().info("NMAVEN-902-001: Found AssemblyInfo file(s), so will not generate one"); + File srcFile = new File( sourceDirectory ); + if ( srcFile.exists() ) + { + try + { + List files = FileUtils.getFiles( srcFile, "**/AssemblyInfo.*", null ); + if ( files.size() != 0 ) + { + getLog().info( "NMAVEN-902-001: Found AssemblyInfo file(s), so will not generate one" ); return; } - } catch (IOException e) { - throw new MojoExecutionException("NMAVEN-902-004: Could not determine whether an AssemblyInfo file exists", - e); + } + catch ( IOException e ) + { + throw new MojoExecutionException( + "NMAVEN-902-004: Could not determine whether an AssemblyInfo file exists", e ); } } - getLog().info("NMAVEN-902-000: Generating Assembly Info: Language = " + language.trim()); - try { - try { - assemblerContext.init(project); - } catch (InitializationException e) { - throw new MojoExecutionException("NMAVEN-902-006: Failed to initialize the assembler context"); + getLog().info( "NMAVEN-902-000: Generating Assembly Info: Language = " + language.trim() ); + try + { + try + { + assemblerContext.init( project ); + } + catch ( InitializationException e ) + { + throw new MojoExecutionException( "NMAVEN-902-006: Failed to initialize the assembler context" ); } - AssemblyInfoMarshaller marshaller = assemblerContext.getAssemblyInfoMarshallerFor(language.trim()); - marshaller.marshal(assemblerContext.getAssemblyInfo(), project, null); - } catch (IOException e) { - throw new MojoExecutionException("NMAVEN-902-002: Problem generating assembly info class", e); - } catch (AssemblyInfoException e) { - throw new MojoExecutionException("NMAVEN-902-005: Problem generating assembly info class", e); + AssemblyInfoMarshaller marshaller = assemblerContext.getAssemblyInfoMarshallerFor( language.trim() ); + marshaller.marshal( assemblerContext.getAssemblyInfo(), project, null ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "NMAVEN-902-002: Problem generating assembly info class", e ); + } + catch ( AssemblyInfoException e ) + { + throw new MojoExecutionException( "NMAVEN-902-005: Problem generating assembly info class", e ); } } Modified: incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/CompilerMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/CompilerMojo.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/CompilerMojo.java (original) +++ incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/CompilerMojo.java Thu Dec 14 14:45:24 2006 @@ -43,7 +43,9 @@ * @phase compile * @description Maven Mojo for compiling Class files to the .NET Intermediate Language */ -public final class CompilerMojo extends AbstractMojo { +public final class CompilerMojo + extends AbstractMojo +{ /** * @parameter expression="${settings.localRepository}" @@ -73,6 +75,7 @@ /** * Specify a strong name key file. (not currently supported) + * @parameter expression = "${keyfile}" */ private File keyfile; @@ -89,7 +92,7 @@ private String platform; /** - * @parameter expression = "${frameworkVersion}" + * @parameter expression = "${frameworkVersion}" */ private String frameworkVersion; @@ -140,56 +143,94 @@ * @throws MojoExecutionException thrown if MOJO is unable to compile the class files or if the environment is not * properly set. */ - public void execute() throws MojoExecutionException { - if (profileAssemblyPath != null && !profileAssemblyPath.exists()) - throw new MojoExecutionException("NMAVEN-900-007: Profile Assembly Path does not exist: Path = " + - profileAssemblyPath.getAbsolutePath()); + public void execute() + throws MojoExecutionException + { + if ( profileAssemblyPath != null && !profileAssemblyPath.exists() ) + { + throw new MojoExecutionException( "NMAVEN-900-007: Profile Assembly Path does not exist: Path = " + + profileAssemblyPath.getAbsolutePath() ); + } //Requirement CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement(); - compilerRequirement.setLanguage(language); - compilerRequirement.setFrameworkVersion(frameworkVersion); - compilerRequirement.setProfile(profile); - compilerRequirement.setVendorVersion(vendorVersion); - try { - if(vendor != null) compilerRequirement.setVendor(VendorFactory.createVendorFromName(vendor)); - } catch (PlatformUnsupportedException e) { - throw new MojoExecutionException("NMAVEN-900-000: Unknown Vendor: Vendor = " + vendor, e); + compilerRequirement.setLanguage( language ); + compilerRequirement.setFrameworkVersion( frameworkVersion ); + compilerRequirement.setProfile( profile ); + compilerRequirement.setVendorVersion( vendorVersion ); + try + { + if ( vendor != null ) + { + compilerRequirement.setVendor( VendorFactory.createVendorFromName( vendor ) ); + } + } + catch ( PlatformUnsupportedException e ) + { + throw new MojoExecutionException( "NMAVEN-900-000: Unknown Vendor: Vendor = " + vendor, e ); } //Config CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig(); - compilerConfig.setLocalRepository(localRepository); - if (parameters != null) compilerConfig.setCommands(parameters); + compilerConfig.setLocalRepository( localRepository ); + if ( parameters != null ) + { + compilerConfig.setCommands( parameters ); + } String artifactTypeName = project.getArtifact().getType(); - if (artifactTypeName.equals(ArtifactType.MODULE.getArtifactTypeName())) { - compilerConfig.setArtifactType(ArtifactType.MODULE); - } else if (artifactTypeName.equals(ArtifactType.LIBRARY.getArtifactTypeName())) { - compilerConfig.setArtifactType(ArtifactType.LIBRARY); - } else if (artifactTypeName.equals(ArtifactType.EXE.getArtifactTypeName())) { - compilerConfig.setArtifactType(ArtifactType.EXE); - } else if (artifactTypeName.equals(ArtifactType.WINEXE.getArtifactTypeName())) { - compilerConfig.setArtifactType(ArtifactType.WINEXE); - } else if (artifactTypeName.equals(ArtifactType.NAR.getArtifactTypeName())) { - compilerConfig.setArtifactType(ArtifactType.LIBRARY); - } else { - throw new MojoExecutionException("NMAVEN-900-001: Unrecognized artifact type: Language = " + language - + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName); - } - - try { - CompilerExecutable compilerExecutable = netExecutableFactory.getCompilerExecutableFor(compilerRequirement, - compilerConfig, project, profileAssemblyPath); + if ( artifactTypeName.equals( ArtifactType.MODULE.getArtifactTypeName() ) ) + { + compilerConfig.setArtifactType( ArtifactType.MODULE ); + } + else if ( artifactTypeName.equals( ArtifactType.LIBRARY.getArtifactTypeName() ) ) + { + compilerConfig.setArtifactType( ArtifactType.LIBRARY ); + } + else if ( artifactTypeName.equals( ArtifactType.EXE.getArtifactTypeName() ) ) + { + compilerConfig.setArtifactType( ArtifactType.EXE ); + } + else if ( artifactTypeName.equals( ArtifactType.WINEXE.getArtifactTypeName() ) ) + { + compilerConfig.setArtifactType( ArtifactType.WINEXE ); + } + else if ( artifactTypeName.equals( ArtifactType.NAR.getArtifactTypeName() ) ) + { + compilerConfig.setArtifactType( ArtifactType.LIBRARY ); + } + else + { + throw new MojoExecutionException( "NMAVEN-900-001: Unrecognized artifact type: Language = " + language + + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName ); + } + + if ( keyfile != null ) + { + KeyInfo keyInfo = KeyInfo.Factory.createDefaultKeyInfo(); + keyInfo.setKeyFileUri( keyfile.getAbsolutePath() ); + compilerConfig.setKeyInfo( keyInfo ); + } + + try + { + CompilerExecutable compilerExecutable = netExecutableFactory.getCompilerExecutableFor( compilerRequirement, + compilerConfig, + project, + profileAssemblyPath ); compilerExecutable.execute(); - project.getArtifact().setFile(compilerExecutable.getCompiledArtifact()); - } catch (PlatformUnsupportedException e) { - throw new MojoExecutionException("NMAVEN-900-003: Unsupported Platform: Language = " + language - + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName, e); - } catch (ExecutionException e) { - throw new MojoExecutionException("NMAVEN-900-004: Unable to Compile: Language = " + language - + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName + ", Source Directory = " - + project.getBuild().getSourceDirectory(), e); + project.getArtifact().setFile( compilerExecutable.getCompiledArtifact() ); + } + catch ( PlatformUnsupportedException e ) + { + throw new MojoExecutionException( "NMAVEN-900-003: Unsupported Platform: Language = " + language + + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName, e ); + } + catch ( ExecutionException e ) + { + throw new MojoExecutionException( "NMAVEN-900-004: Unable to Compile: Language = " + language + + ", Vendor = " + vendor + ", ArtifactType = " + artifactTypeName + ", Source Directory = " + + project.getBuild().getSourceDirectory(), e ); } } } Modified: incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestCompilerMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestCompilerMojo.java?view=diff&rev=487379&r1=487378&r2=487379 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestCompilerMojo.java (original) +++ incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/java/org/apache/maven/dotnet/plugin/compile/TestCompilerMojo.java Thu Dec 14 14:45:24 2006 @@ -38,7 +38,9 @@ * @phase test-compile * @description Maven Mojo for compiling Test Class files to the .NET Intermediate Language */ -public final class TestCompilerMojo extends AbstractMojo { +public final class TestCompilerMojo + extends AbstractMojo +{ /** * @parameter expression="${settings.localRepository}" @@ -69,7 +71,7 @@ private boolean skipTestCompile; /** - * @parameter expression = "${testFrameworkVersion}" + * @parameter expression = "${testFrameworkVersion}" */ private String testFrameworkVersion; @@ -120,47 +122,69 @@ * @throws MojoExecutionException thrown if MOJO is unable to compile the class files or if the environment is not * properly set. */ - public void execute() throws MojoExecutionException { - String skipTests = System.getProperty("maven.test.skip"); - if ((skipTests != null && skipTests.equalsIgnoreCase("true")) || skipTestCompile) { - getLog().warn("NMAVEN-903-004: Disabled unit tests: -Dmaven.test.skip=true"); + public void execute() + throws MojoExecutionException + { + String skipTests = System.getProperty( "maven.test.skip" ); + if ( ( skipTests != null && skipTests.equalsIgnoreCase( "true" ) ) || skipTestCompile ) + { + getLog().warn( "NMAVEN-903-004: Disabled unit tests: -Dmaven.test.skip=true" ); return; } - FileUtils.mkdir("target"); + FileUtils.mkdir( "target" ); - if (testLanguage == null) testLanguage = language; - if (testVendor == null) testVendor = vendor; + if ( testLanguage == null ) + { + testLanguage = language; + } + if ( testVendor == null ) + { + testVendor = vendor; + } //Requirement CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement(); - compilerRequirement.setLanguage(language); - compilerRequirement.setFrameworkVersion(testFrameworkVersion); - compilerRequirement.setProfile("FULL"); - compilerRequirement.setVendorVersion(testVendorVersion); - try { - if(vendor != null) compilerRequirement.setVendor(VendorFactory.createVendorFromName(vendor)); - } catch (PlatformUnsupportedException e) { - throw new MojoExecutionException("NMAVEN-900-000: Unknown Vendor: Vendor = " + vendor, e); + compilerRequirement.setLanguage( language ); + compilerRequirement.setFrameworkVersion( testFrameworkVersion ); + compilerRequirement.setProfile( "FULL" ); + compilerRequirement.setVendorVersion( testVendorVersion ); + try + { + if ( vendor != null ) + { + compilerRequirement.setVendor( VendorFactory.createVendorFromName( vendor ) ); + } + } + catch ( PlatformUnsupportedException e ) + { + throw new MojoExecutionException( "NMAVEN-900-000: Unknown Vendor: Vendor = " + vendor, e ); } - //Config CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig(); - if (testParameters != null) compilerConfig.setCommands(testParameters); - compilerConfig.setArtifactType(ArtifactType.LIBRARY); - compilerConfig.setTestCompile(true); - compilerConfig.setLocalRepository(localRepository); - - try { - CompilerExecutable compilerExecutable = netExecutableFactory.getCompilerExecutableFor(compilerRequirement, - compilerConfig, project, null); + if ( testParameters != null ) + { + compilerConfig.setCommands( testParameters ); + } + compilerConfig.setArtifactType( ArtifactType.LIBRARY ); + compilerConfig.setTestCompile( true ); + compilerConfig.setLocalRepository( localRepository ); + + try + { + CompilerExecutable compilerExecutable = + netExecutableFactory.getCompilerExecutableFor( compilerRequirement, compilerConfig, project, null ); compilerExecutable.execute(); - } catch (PlatformUnsupportedException e) { - throw new MojoExecutionException("NMAVEN-903-003: Unsupported Platform: Language = " + language - + ", Vendor = " + vendor, e); - } catch (ExecutionException e) { - throw new MojoExecutionException("NMAVEN-903-002: Unable to Compile: Language = " + language - + ", Vendor = " + vendor, e); + } + catch ( PlatformUnsupportedException e ) + { + throw new MojoExecutionException( + "NMAVEN-903-003: Unsupported Platform: Language = " + language + ", Vendor = " + vendor, e ); + } + catch ( ExecutionException e ) + { + throw new MojoExecutionException( + "NMAVEN-903-002: Unable to Compile: Language = " + language + ", Vendor = " + vendor, e ); } } }