Author: sisbell
Date: Tue Dec 19 10:24:53 2006 New Revision: 488750 URL: http://svn.apache.org/viewvc?view=rev&rev=488750 Log: Added support for signing assemblies for MS version 1.1. Signing needs to be handled differently for v1.1 Removed: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoUnmarshaller.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshaller.java Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfo.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.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/resources/META-INF/plexus/components.xml Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfo.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfo.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfo.java Tue Dec 19 10:24:53 2006 @@ -18,6 +18,8 @@ */ package org.apache.maven.dotnet.assembler; +import java.io.File; + /** * Provides the information to be included within the assembly. Class can be extended to add additional assembly info * parameters. @@ -71,6 +73,10 @@ */ private String configuration; + private String keyName; + + private File keyFile; + /** * Default constructor */ @@ -93,6 +99,26 @@ return sb.toString(); } + public String getKeyName() + { + return keyName; + } + + public void setKeyName( String keyName ) + { + this.keyName = keyName; + } + + public File getKeyFile() + { + return keyFile; + } + + public void setKeyFile( File keyFile ) + { + this.keyFile = keyFile; + } + public String getVersion() { return ( version != null ) ? version : ""; @@ -182,6 +208,7 @@ { this.configuration = configuration; } + public boolean equals( Object o ) { Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/AssemblyInfoMarshaller.java Tue Dec 19 10:24:53 2006 @@ -20,6 +20,7 @@ import java.io.OutputStream; import java.io.IOException; +import java.io.InputStream; import org.apache.maven.project.MavenProject; import org.apache.maven.dotnet.model.assembly.plugins.AssemblyPlugin; @@ -42,6 +43,8 @@ */ void marshal( AssemblyInfo assemblyInfo, MavenProject mavenProject, OutputStream outputStream ) throws IOException; + + AssemblyInfo unmarshall( InputStream inputStream) throws IOException; /** * Initializes the marshaller. Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/AssemblerContextImpl.java Tue Dec 19 10:24:53 2006 @@ -137,7 +137,7 @@ { AssemblyPlugin plugin = repository.getAssemblyPluginFor( language ); String className = plugin.getPluginClass(); - AssemblyInfoMarshaller marshaller = null; + AssemblyInfoMarshaller marshaller; try { Class cc = Class.forName( className ); Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java Tue Dec 19 10:24:53 2006 @@ -26,6 +26,9 @@ import java.io.IOException; import java.io.File; import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; import org.apache.maven.project.MavenProject; @@ -63,6 +66,9 @@ .append( createEntry( "Culture", assemblyInfo.getCulture() ) ) .append( createEntry( "Version", assemblyInfo.getVersion() ) ) .append( createEntry( "Configuration", assemblyInfo.getConfiguration() ) ); + if(assemblyInfo.getKeyName() != null) sb.append( createEntry( "KeyName", assemblyInfo.getKeyName() ) ); + if(assemblyInfo.getKeyFile() != null) + sb.append(createEntry("KeyFile", assemblyInfo.getKeyFile().getAbsolutePath())); FileOutputStream man = null; try { @@ -91,6 +97,51 @@ public void init( AssemblyPlugin plugin ) { this.plugin = plugin; + } + + 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); + } else if(name.equals("AssemblyKeyFile")) { + assemblyInfo.setConfiguration(value); + } else if(name.equals("AssemblyKeyName")) { + assemblyInfo.setConfiguration(value); + } } /** Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java Tue Dec 19 10:24:53 2006 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.FileOutputStream; import java.io.File; +import java.io.InputStream; import org.apache.maven.project.MavenProject; @@ -82,6 +83,12 @@ man.close(); } } + } + + public AssemblyInfo unmarshall( InputStream inputStream ) + throws IOException + { + return null; } /** Modified: incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java Tue Dec 19 10:24:53 2006 @@ -26,6 +26,7 @@ import java.io.IOException; import java.io.FileOutputStream; import java.io.File; +import java.io.InputStream; import org.apache.maven.project.MavenProject; @@ -85,6 +86,12 @@ } } + public AssemblyInfo unmarshall( InputStream inputStream ) + throws IOException + { + return null; + } + /** * @see AssemblyInfoMarshaller#init(org.apache.maven.dotnet.model.assembly.plugins.AssemblyPlugin) */ Modified: 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=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java (original) +++ incubator/nmaven/branches/SI_SIGNING/components/dotnet-assembler/src/test/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoUnmarshallerTest.java Tue Dec 19 10:24:53 2006 @@ -5,7 +5,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.File; import org.apache.maven.dotnet.assembler.AssemblyInfo; @@ -27,7 +26,7 @@ fail("Could not find test file"); } - DefaultAssemblyInfoUnmarshaller um = new DefaultAssemblyInfoUnmarshaller(); + DefaultAssemblyInfoMarshaller um = new DefaultAssemblyInfoMarshaller(); try { AssemblyInfo assemblyInfo = um.unmarshall( fis ); 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=488750&r1=488749&r2=488750 ============================================================================== --- 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 Tue Dec 19 10:24:53 2006 @@ -28,9 +28,11 @@ import java.util.List; import org.apache.maven.dotnet.InitializationException; +import org.apache.maven.dotnet.vendor.*; import org.apache.maven.dotnet.assembler.AssemblerContext; import org.apache.maven.dotnet.assembler.AssemblyInfoMarshaller; import org.apache.maven.dotnet.assembler.AssemblyInfoException; +import org.apache.maven.dotnet.assembler.AssemblyInfo; /** * Generates an AssemblyInfo.* class based on information within the pom file. @@ -53,6 +55,16 @@ private MavenProject project; /** + * @parameter expression = "${frameworkVersion}" + */ + private String frameworkVersion; + + /** + * @parameter expression = "${vendorVersion}" + */ + private String vendorVersion; + + /** * .NET Language. The default value is <code>C_SHARP</code>. Not case or white-space sensitive. * * @parameter expression="${language}" default-value = "C_SHARP" @@ -61,11 +73,37 @@ private String language; /** + * The Vendor for the Compiler. Not case or white-space sensitive. + * + * @parameter expression="${vendor}" + */ + private String vendor; + + /** + * Specify a strong name key file. + * + * @parameter expression = "${keyfile}" + */ + private File keyfile; + + /** + * Specifies a strong name key container. (not currently supported) + * + * @parameter expression = "${keycontainer}" + */ + private String keycontainer; + + /** * @component */ private AssemblerContext assemblerContext; /** + * @component + */ + private org.apache.maven.dotnet.vendor.StateMachineProcessor stateMachineProcessor; + + /** * Source directory * * @parameter expression = "${sourceDirectory}" default-value="${project.build.sourceDirectory}" @@ -105,18 +143,54 @@ } } getLog().info( "NMAVEN-902-000: Generating Assembly Info: Language = " + language.trim() ); + try { - try - { - assemblerContext.init( project ); - } - catch ( InitializationException e ) + assemblerContext.init( project ); + } + catch ( InitializationException e ) + { + throw new MojoExecutionException( "NMAVEN-902-006: Failed to initialize the assembler context" ); + } + + //TODO: Investigate the affect of not setting isDefault and profile. In the case of executables, this is + //managed by the framework. I intended to keep vendor info and state machine processor out of the + // Mojos. Unable to do so for this case. Look at new API. + VendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo(); + try + { + vendorInfo.setFrameworkVersion( frameworkVersion ); + if ( vendor != null ) { - throw new MojoExecutionException( "NMAVEN-902-006: Failed to initialize the assembler context" ); + vendorInfo.setVendor( VendorFactory.createVendorFromName( vendor ) ); } + vendorInfo.setVendorVersion( vendorVersion ); + } + catch ( VendorUnsupportedException e ) + { + throw new MojoExecutionException( "NMAVEN-902-007: Vendor not supported: Vendor = " + vendor ); + } + + AssemblyInfo assemblyInfo = assemblerContext.getAssemblyInfo(); + try + { + stateMachineProcessor.process( vendorInfo ); + } + catch ( org.apache.maven.dotnet.vendor.IllegalStateException e ) + { + throw new MojoExecutionException( + "NMAVEN-902-008: Illegal state of vendor info: Message = " + e.getMessage() ); + } + + if ( vendorInfo.getVendor().equals( Vendor.MICROSOFT ) && vendorInfo.getVendorVersion().equals( "1.1.4322" ) ) + { + assemblyInfo.setKeyFile( keyfile ); + assemblyInfo.setKeyName( keycontainer ); + } + try + { AssemblyInfoMarshaller marshaller = assemblerContext.getAssemblyInfoMarshallerFor( language.trim() ); - marshaller.marshal( assemblerContext.getAssemblyInfo(), project, null ); + marshaller.marshal( assemblyInfo, project, null ); } catch ( IOException 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=488750&r1=488749&r2=488750 ============================================================================== --- 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 Tue Dec 19 10:24:53 2006 @@ -114,7 +114,7 @@ private String language; /** - * The Vendor for the Compiler. Supports MONO and MICROSOFT: the default value is <code>MICROSOFT</code>. Not + * The Vendor for the Compiler. Not * case or white-space sensitive. * * @parameter expression="${vendor}" Modified: incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=488750&r1=488749&r2=488750 ============================================================================== --- incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/resources/META-INF/plexus/components.xml (original) +++ incubator/nmaven/branches/SI_SIGNING/plugins/maven-compile-plugin/src/main/resources/META-INF/plexus/components.xml Tue Dec 19 10:24:53 2006 @@ -211,5 +211,26 @@ </requirement> </requirements> </component> + <component> + <role>org.apache.maven.dotnet.vendor.VendorInfoRepository</role> + <implementation>org.apache.maven.dotnet.vendor.impl.VendorInfoRepositoryImpl</implementation> + <requirements> + <requirement> + <role>org.apache.maven.dotnet.registry.RepositoryRegistry</role> + </requirement> + </requirements> + </component> + <component> + <role>org.apache.maven.dotnet.vendor.StateMachineProcessor</role> + <implementation>org.apache.maven.dotnet.vendor.impl.StateMachineProcessorImpl</implementation> + <requirements> + <requirement> + <role>org.apache.maven.dotnet.vendor.VendorInfoRepository</role> + </requirement> + <requirement> + <role>org.apache.maven.dotnet.registry.RepositoryRegistry</role> + </requirement> + </requirements> + </component> </components> </component-set> |
Free forum by Nabble | Edit this page |