Author: sisbell Date: Tue Dec 4 13:24:04 2007 New Revision: 601087 URL: http://svn.apache.org/viewvc?rev=601087&view=rev Log: Moved over compiler and marshallers into separate package.
Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml (with props) incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java (with props) incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java (with props) incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java (with props) incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java (with props) Removed: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/DefaultAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/JavaAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/main/java/org/apache/maven/dotnet/assembler/impl/VBAssemblyInfoMarshaller.java incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-assembler/src/test/ Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/pom.xml Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml?rev=601087&view=auto ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml (added) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml Tue Dec 4 13:24:04 2007 @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- +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. +--> +<project 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"> + <parent> + <groupId>org.apache.maven.dotnet</groupId> + <version>0.14-incubating-SNAPSHOT</version> + <artifactId>dotnet-components</artifactId> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.apache.maven.dotnet</groupId> + <artifactId>dotnet-extensions-maven</artifactId> + <name>dotnet-extensions-maven</name> + <description>NMaven</description> + + <!-- The version of maven components/plugins that we depend on --> + <properties> + <mavenVersion>2.0.8</mavenVersion> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven.dotnet</groupId> + <artifactId>dotnet-compiler</artifactId> + <version>${parent.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.dotnet</groupId> + <artifactId>dotnet-assembler</artifactId> + <version>${parent.version}</version> + </dependency> + <dependency> + <groupId>org.apache.maven.dotnet</groupId> + <artifactId>dotnet-core</artifactId> + <version>${parent.version}</version> + </dependency> + </dependencies> +</project> Propchange: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java?rev=601087&view=auto ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java (added) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java Tue Dec 4 13:24:04 2007 @@ -0,0 +1,200 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.extensions.assembler; + +import org.apache.maven.dotnet.assembler.AssemblyInfoMarshaller; +import org.apache.maven.dotnet.assembler.AssemblyInfo; +import org.apache.maven.dotnet.ProgrammingLanguage; + +import java.io.OutputStream; +import java.io.IOException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.BufferedReader; +import java.io.InputStreamReader; + +/** + * Provides services for writing out the AssemblyInfo entries using the bracket convention [assembly: + */ +public final class DefaultAssemblyInfoMarshaller + implements AssemblyInfoMarshaller +{ + private ProgrammingLanguage programmingLanguage; + + private File buildSourcesDirectory; + + public void marshal( AssemblyInfo assemblyInfo, File buildDirectory, OutputStream outputStream ) + throws IOException + { + StringBuffer sb = new StringBuffer(); + sb.append( "using System.Reflection;\r\n" ) + .append( "using System.Runtime.CompilerServices;\r\n" ) + .append( createEntry( "Description", assemblyInfo.getDescription() ) ) + .append( createEntry( "Title", assemblyInfo.getTitle() ) ) + .append( createEntry( "Company", assemblyInfo.getCompany() ) ) + .append( createEntry( "Product", assemblyInfo.getProduct() ) ) + .append( createEntry( "Copyright", assemblyInfo.getCopyright().replace( "\"", "\\" ) ) ) + .append( createEntry( "Trademark", assemblyInfo.getTrademark() ) ) + .append( createEntry( "Culture", assemblyInfo.getCulture() ) ) + .append( createEntry( "Version", assemblyInfo.getVersion() ) ) + .append( createEntry( "InformationalVersion", assemblyInfo.getInformationalVersion() ) ) + .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().replace( "\\", "\\\\" ) ) ); + } + FileOutputStream assemblyInfoFileStream = null; + try + { + File metaInfoDir = new File( buildSourcesDirectory, "META-INF" ); + metaInfoDir.mkdirs(); + assemblyInfoFileStream = new FileOutputStream( + metaInfoDir + File.separator + "AssemblyInfo." + programmingLanguage.getClassFileExtension() ); + assemblyInfoFileStream.write( sb.toString().getBytes() ); + } + catch ( IOException e ) + { + e.printStackTrace(); + throw new IOException( "NMAVEN-022-000: Failed to generate AssemblyInfo" ); + } + finally + { + if ( assemblyInfoFileStream != null ) + { + assemblyInfoFileStream.close(); + } + } + } + + /** + * @see AssemblyInfoMarshaller#unmarshall(java.io.InputStream) + */ + 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; + } + + public void init( ProgrammingLanguage programmingLanguage, File buildSourcesDirectory ) + { + this.programmingLanguage = programmingLanguage; + this.buildSourcesDirectory = buildSourcesDirectory; + } + + /** + * Sets the specified value within the specified assembly info + * + * @param assemblyInfo the assembly info to set information on + * @param name the name of the assembly info field: AssemblyTitle, AssemblyDescription, ... + * @param value the value associated with the specified name + * @throws IOException if the assembly info is invalid + */ + private static void setAssemblyInfo( AssemblyInfo assemblyInfo, String name, String value ) + throws IOException + { + if ( !name.startsWith( "Assembly" ) ) + { + throw new IOException( + "NMAVEN-022-001: Invalid assembly info parameter: Name = " + name + ", Value = " + value ); + } + if ( name.equals( "AssemblyDescription" ) ) + { + assemblyInfo.setDescription( value ); + } + else if ( name.equals( "AssemblyInformationalVersion" ) ) + { + assemblyInfo.setInformationalVersion( 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 ); + } + } + + /** + * Returns an assembly entry with a name-value pair surrounded by brackets. + * + * @param name the name of the assembly entry + * @param value the value of the assembly entry + * @return an assembly entry with a name-value pair surrounded by brackets + */ + private static String createEntry( String name, String value ) + { + StringBuffer sb = new StringBuffer(); + sb.append( "[assembly: Assembly" ).append( name ).append( "(\"" ).append( value ).append( "\")]" ).append( + "\r\n" ); + return sb.toString(); + } +} Propchange: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/DefaultAssemblyInfoMarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java?rev=601087&view=auto ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java (added) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java Tue Dec 4 13:24:04 2007 @@ -0,0 +1,111 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.extensions.assembler; + +import org.apache.maven.dotnet.assembler.AssemblyInfoMarshaller; +import org.apache.maven.dotnet.assembler.AssemblyInfo; +import org.apache.maven.dotnet.ProgrammingLanguage; + +import java.io.OutputStream; +import java.io.IOException; +import java.io.FileOutputStream; +import java.io.File; +import java.io.InputStream; + +/** + * Provides services for writing out the AssemblyInfo entries for Java, where each entry begins with '/**@' and ends with '*\/' + * + * @author Shane Isbell + */ +public final class JavaAssemblyInfoMarshaller + implements AssemblyInfoMarshaller +{ + private ProgrammingLanguage programmingLanguage; + + private File buildSourcesDirectory; + + public void marshal( AssemblyInfo assemblyInfo, File buildDirectory, OutputStream outputStream ) + throws IOException + { + StringBuffer sb = new StringBuffer(); + sb.append( "import System.Reflection;\r\n" ) + .append( "import System.Runtime.CompilerServices.*;r\n" ) + .append( createEntry( "Description", assemblyInfo.getDescription() ) ) + .append( createEntry( "Title", assemblyInfo.getTitle() ) ) + .append( createEntry( "Company", assemblyInfo.getCompany() ) ) + .append( createEntry( "Product", assemblyInfo.getProduct() ) ) + .append( createEntry( "Copyright", assemblyInfo.getCopyright().replace( "\"", "\\" ) ) ) + .append( createEntry( "Trademark", assemblyInfo.getTrademark() ) ) + .append( createEntry( "Culture", assemblyInfo.getCulture() ) ) + .append( createEntry( "Version", assemblyInfo.getVersion() ) ) + .append( createEntry( "Configuration", assemblyInfo.getConfiguration() ) ); + + FileOutputStream assemblyInfoFileStream = null; + try + { + File metaInfoDir = new File( buildSourcesDirectory, "META-INF" ); + metaInfoDir.mkdirs(); + assemblyInfoFileStream = new FileOutputStream( + metaInfoDir + File.separator + "AssemblyInfo." + programmingLanguage.getClassFileExtension() ); + assemblyInfoFileStream.write( sb.toString().getBytes() ); + } + catch ( IOException e ) + { + e.printStackTrace(); + throw new IOException( "NMAVEN-022-000: Failed to generate AssemblyInfo" ); + } + finally + { + if ( assemblyInfoFileStream != null ) + { + assemblyInfoFileStream.close(); + } + } + } + + /** + * @see AssemblyInfoMarshaller#unmarshall(java.io.InputStream) + */ + public AssemblyInfo unmarshall( InputStream inputStream ) + throws IOException + { + throw new IOException( "This method is not implemented" ); + } + + public void init( ProgrammingLanguage programmingLanguage, File buildSourcesDirectory ) + { + this.programmingLanguage = programmingLanguage; + this.buildSourcesDirectory = buildSourcesDirectory; + } + + /** + * Returns an assembly entry with a name-value pair beginning with '/**@' and ending with '*\/' + * + * @param name the name of the assembly entry + * @param value the value of the assembly entry + * @return an assembly entry with a name-value pair beginning with '/**@' and ending with '*\/' + */ + private String createEntry( String name, String value ) + { + StringBuffer sb = new StringBuffer(); + sb.append( "/[EMAIL PROTECTED]: Assembly" ).append( name ).append( "(\"" ).append( value ).append( "\")*/" ).append( + "\r\n" ); + return sb.toString(); + } +} Propchange: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/JavaAssemblyInfoMarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java?rev=601087&view=auto ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java (added) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java Tue Dec 4 13:24:04 2007 @@ -0,0 +1,111 @@ +/* + * 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. + */ +package org.apache.maven.dotnet.extensions.assembler; + +import org.apache.maven.dotnet.assembler.AssemblyInfoMarshaller; +import org.apache.maven.dotnet.assembler.AssemblyInfo; +import org.apache.maven.dotnet.ProgrammingLanguage; + +import java.io.OutputStream; +import java.io.IOException; +import java.io.FileOutputStream; +import java.io.File; +import java.io.InputStream; + +/** + * Provides services for writing out the AssemblyInfo entries for VB using the angle bracket convention <assembly: + * + * @author Shane Isbell + */ + +public final class VBAssemblyInfoMarshaller + implements AssemblyInfoMarshaller +{ + private ProgrammingLanguage programmingLanguage; + + private File buildSourcesDirectory; + + public void marshal( AssemblyInfo assemblyInfo, File buildDirectory, OutputStream outputStream ) + throws IOException + { + StringBuffer sb = new StringBuffer(); + sb.append( "Imports System.Reflection\r\n" ) + .append( "Imports System.Runtime.InteropServices\r\n" ) + .append( createEntry( "Description", assemblyInfo.getDescription() ) ) + .append( createEntry( "Title", assemblyInfo.getTitle() ) ) + .append( createEntry( "Company", assemblyInfo.getCompany() ) ) + .append( createEntry( "Product", assemblyInfo.getProduct() ) ) + .append( createEntry( "Copyright", assemblyInfo.getCopyright().replace( "\"", "\\" ) ) ) + .append( createEntry( "Trademark", assemblyInfo.getTrademark() ) ) + .append( createEntry( "Culture", assemblyInfo.getCulture() ) ) + .append( createEntry( "Version", assemblyInfo.getVersion() ) ); + + FileOutputStream assemblyInfoFileStream = null; + try + { + File metaInfoDir = new File( buildSourcesDirectory, "META-INF" ); + metaInfoDir.mkdirs(); + assemblyInfoFileStream = new FileOutputStream( + metaInfoDir + File.separator + "AssemblyInfo." + programmingLanguage.getClassFileExtension() ); + assemblyInfoFileStream.write( sb.toString().getBytes() ); + } + catch ( IOException e ) + { + e.printStackTrace(); + throw new IOException( "NMAVEN-022-000: Failed to generate AssemblyInfo" ); + } + finally + { + if ( assemblyInfoFileStream != null ) + { + assemblyInfoFileStream.close(); + } + } + } + + /** + * @see AssemblyInfoMarshaller#unmarshall(java.io.InputStream) + */ + public AssemblyInfo unmarshall( InputStream inputStream ) + throws IOException + { + throw new IOException( "This method is not implemented" ); + } + + public void init( ProgrammingLanguage programmingLanguage, File buildSourcesDirectory ) + { + this.programmingLanguage = programmingLanguage; + this.buildSourcesDirectory = buildSourcesDirectory; + } + + /** + * Returns an assembly entry with a name-value pair surrounded by angle brackets. + * + * @param name the name of the assembly entry + * @param value the value of the assembly entry + * @return an assembly entry with a name-value pair surrounded by angle brackets + */ + private String createEntry( String name, String value ) + { + StringBuffer sb = new StringBuffer(); + sb.append( "<Assembly: Assembly" ).append( name ).append( "(\"" ).append( value ).append( "\")>" ).append( + "\r\n" ); + return sb.toString(); + } +} Propchange: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/assembler/VBAssemblyInfoMarshaller.java ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java?rev=601087&view=auto ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java (added) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java Tue Dec 4 13:24:04 2007 @@ -0,0 +1,192 @@ +package org.apache.maven.dotnet.extensions.compiler; + +import java.io.File; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.dotnet.compiler.CommandExecutor; +import org.apache.maven.dotnet.compiler.CompilerAnnotation; +import org.apache.maven.dotnet.compiler.CompilerContext; +import org.apache.maven.dotnet.compiler.CompilerException; +import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; +import org.apache.maven.dotnet.compiler.DotnetCompilerContext; +import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion; +import org.apache.maven.dotnet.compiler.InvalidArtifactException; +import org.apache.maven.dotnet.ProgrammingLanguage; +import org.apache.maven.dotnet.Vendor; + [EMAIL PROTECTED](programmingLanguaqe = ProgrammingLanguage.C_SHARP, + vendors = {Vendor.MICROSOFT, Vendor.NOVELL, Vendor.ANY}, + dotnetCompilerPlatformVersions = {DotnetCompilerPlatformVersion.VERSION_2_0_50727, DotnetCompilerPlatformVersion.VERSION_3_0}) +public class CSharpClassCompiler + implements org.apache.maven.dotnet.compiler.ClassCompiler +{ + private DotnetCompilerContext compilerContext; + + private File compiledArtifact; + + public File getCompiledArtifact() + throws InvalidArtifactException + { + if ( compiledArtifact == null || !compiledArtifact.exists() ) + { + throw new InvalidArtifactException(); + } + return compiledArtifact; + } + + public boolean failOnErrorOutput() + { + return false; + } + + public Set<String> getCommands() + { + DotnetCompilerConfig config = (DotnetCompilerConfig) compilerContext.getCompilerConfig(); + Set<Artifact> references = compilerContext.getLibraryDependencies(); + Set<Artifact> modules = compilerContext.getDirectModuleDependencies(); + + File sourceDirectory = config.getCompilerDirectory(); + compiledArtifact = + new File( config.getTargetDirectory(), compilerContext.getCompilerConfig().getArtifactFileName() ); + String targetArtifactType = config.getArtifactType().getTargetCompileType(); + + Set<String> commands = new HashSet<String>(); + commands.add( "/out:" + compiledArtifact.getAbsolutePath() ); + commands.add( "/target:" + targetArtifactType ); + commands.add( "/recurse:" + sourceDirectory + File.separator + "**" ); + if ( modules != null && !modules.isEmpty() ) + { + StringBuffer sb = new StringBuffer(); + for ( Iterator i = modules.iterator(); i.hasNext(); ) + { + Artifact artifact = (Artifact) i.next(); + String path = artifact.getFile().getAbsolutePath(); + sb.append( path ); + if ( i.hasNext() ) + { + sb.append( ";" ); + } + } + commands.add( "/addmodule:" + sb.toString() ); + } + if ( !references.isEmpty() ) + { + for ( Artifact artifact : references ) + { + String path = artifact.getFile().getAbsolutePath(); + commands.add( "/reference:" + path ); + } + } + + for ( File file : compilerContext.getEmbeddedResources() ) + { + commands.add( "/resource:" + file.getAbsolutePath() ); + } + for ( File file : compilerContext.getLinkedResources() ) + { + commands.add( "/linkresource:" + file.getAbsolutePath() ); + } + for ( File file : compilerContext.getWin32Resources() ) + { + commands.add( "/win32res:" + file.getAbsolutePath() ); + } + if ( compilerContext.getWin32Icon() != null ) + { + commands.add( "/win32icon:" + compilerContext.getWin32Icon().getAbsolutePath() ); + } + + if ( config.getVendor().equals( Vendor.MICROSOFT ) ) + { + commands.add( "/nologo" ); + } + + if ( config.getVendor().equals( Vendor.MICROSOFT ) && + config.getCompilerPlatformVersion().equals( DotnetCompilerPlatformVersion.VERSION_3_0 ) ) + { + String wcfRef = "/reference:" + System.getenv( "SystemRoot" ) + + "\\Microsoft.NET\\Framework\\v3.0\\Windows Communication Foundation\\"; + //TODO: This is a hard-coded path: Don't have a registry value either. + commands.add( wcfRef + "System.ServiceModel.dll" ); + commands.add( wcfRef + "Microsoft.Transactions.Bridge.dll" ); + commands.add( wcfRef + "Microsoft.Transactions.Bridge.Dtc.dll" ); + commands.add( wcfRef + "System.ServiceModel.Install.dll" ); + commands.add( wcfRef + "System.ServiceModel.WasHosting.dll" ); + commands.add( wcfRef + "System.Runtime.Serialization.dll" ); + commands.add( wcfRef + "SMDiagnostics.dll" ); + } + + if ( config.getKeyInfo().getKeyFileUri() != null ) + { + commands.add( "/keyfile:" + config.getKeyInfo().getKeyFileUri() ); + } + else if ( config.getKeyInfo().getKeyContainerName() != null ) + { + commands.add( "/keycontainer:" + config.getKeyInfo().getKeyContainerName() ); + } +/* + if ( config.getCommands() != null ) + { + commands.addAll( config.getCommands() ); + } + */ + commands.add( "/warnaserror-" ); + if ( config.getVendor().equals( Vendor.NOVELL ) ) + { + commands.add( "/reference:System.Drawing" ); + commands.add( "/reference:System.Windows.Forms" ); + commands.add( "/reference:System.Web.Services" ); + } + if ( !config.isTestCompile() ) + { + commands.add( "/doc:" + new File( config.getTargetDirectory(), "comments.xml" ).getAbsolutePath() ); + } + return commands; + } + + public void resetCommands( Set<String> commands ) + { + + } + + public void compile() + { + CommandExecutor commandExecutor = CommandExecutor.Factory.createDefaultCommmandExecutor(); + //commandExecutor.setLogger( logger ); + try + { + commandExecutor.executeCommand( getCompilerFileName(), getCommands() ); + } + catch ( CompilerException e ) + { + e.printStackTrace(); + } + } + + public String getCompilerFileName() + { + if ( compilerContext.getCompilerConfig().getVendor().equals( Vendor.MICROSOFT ) ) + { + return "csc"; + } + else if ( compilerContext.getCompilerConfig().getVendor().equals( Vendor.NOVELL ) ) + { + return "gmcs"; + } + else + { + return null; + } + } + + public void init( CompilerContext compilerContext ) + { + if ( compilerContext == null || ! ( compilerContext instanceof DotnetCompilerContext ) ) + { + throw new IllegalArgumentException( "compilerContext" ); + } + this.compilerContext = (DotnetCompilerContext) compilerContext; + } +} Propchange: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/dotnet-extensions-maven/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/pom.xml?rev=601087&r1=601086&r2=601087&view=diff ============================================================================== --- incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/pom.xml (original) +++ incubator/nmaven/branches/SI_MAVEN_INTEGRATION/sandbox/components/pom.xml Tue Dec 4 13:24:04 2007 @@ -32,7 +32,7 @@ <module>dotnet-assembler</module> <module>dotnet-core</module> <module>dotnet-compiler</module> - <module>dotnet-compiler-ext</module> + <module>dotnet-extensions-maven</module> </modules> <dependencies> <dependency>