You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by jf...@apache.org on 2011/07/09 22:59:17 UTC
svn commit: r1144760 - in /incubator/npanday/trunk:
components/dotnet-core/src/main/resources/META-INF/npanday/
components/dotnet-executable/src/main/java/npanday/executable/
components/dotnet-executable/src/main/java/npanday/executable/compiler/
compo...
Author: jfallows
Date: Sat Jul 9 22:59:17 2011
New Revision: 1144760
URL: http://svn.apache.org/viewvc?rev=1144760&view=rev
Log:
Move target framework to from plugin attribute to compiler-plugins.xml
Modified:
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
Modified: incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml (original)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml Sat Jul 9 22:59:17 2011
@@ -224,6 +224,7 @@ under the License.
<architecture>x86</architecture>
</platform>
</platforms>
+ <targetFramework>.NETPortable,Version=v4.0,Profile=Profile2</targetFramework>
<defaultAssemblyPath>C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile2</defaultAssemblyPath>
<assemblies>
<assembly>mscorlib</assembly>
@@ -652,6 +653,7 @@ under the License.
<operatingSystem>FreeBSD</operatingSystem>
</platform>
</platforms>
+ <targetFramework>.NETPortable,Version=v4.0,Profile=Profile2</targetFramework>
<!-- Mono 2.10.2 missing .NETPortable defaultAssemblyPath, requires profileAssemblyPath -->
<assemblies>
<assembly>mscorlib</assembly>
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/ExecutableCapability.java Sat Jul 9 22:59:17 2011
@@ -232,6 +232,8 @@ public interface ExecutableCapability
private String netDependencyId;
+ private String targetFramework;
+
public String getAssemblyPath()
{
return assemblyPath;
@@ -312,6 +314,16 @@ public interface ExecutableCapability
this.language = language;
}
+ public String getTargetFramework()
+ {
+ return targetFramework;
+ }
+
+ public void setTargetFramework( String targetFramework )
+ {
+ this.targetFramework = targetFramework;
+ }
+
public String getOperatingSystem()
{
return operatingSystem;
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerCapability.java Sat Jul 9 22:59:17 2011
@@ -67,6 +67,13 @@ public interface CompilerCapability
boolean isHasJustInTime();
/**
+ * Returns the target framework of the plugin.
+ *
+ * @return the target framework of the plugin.
+ */
+ String getTargetFramework();
+
+ /**
* Sets the assembly path.
*
* @param assemblyPath
@@ -95,4 +102,11 @@ public interface CompilerCapability
*/
void setHasJustInTime( boolean hasJustInTime );
+ /**
+ * Set the target framework capability of the compiler.
+ *
+ * @param targetFramework
+ */
+ void setTargetFramework( String targetFramework );
+
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/CompilerExecutable.java Sat Jul 9 22:59:17 2011
@@ -33,6 +33,13 @@ public interface CompilerExecutable
{
/**
+ * Returns the target framework for this compiler executable.
+ *
+ * @return the target framework for this compiler executable
+ */
+ String getTargetFramework();
+
+ /**
* Returns a file pointing to the compiled artifact for this executable.
*
* @return a file pointing to the compiled artifact for this executable
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/BaseCompiler.java Sat Jul 9 22:59:17 2011
@@ -59,6 +59,14 @@ abstract class BaseCompiler implements C
}
/**
+ * @see npanday.executable.compiler.CompilerExecutable#getTargetFramework()
+ */
+ public String getTargetFramework()
+ {
+ return compilerContext.getCompilerCapability().getTargetFramework();
+ }
+
+ /**
* @see npanday.executable.compiler.CompilerExecutable#getCompiledArtifact()
*/
public File getCompiledArtifact()
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java Sat Jul 9 22:59:17 2011
@@ -120,6 +120,7 @@ public final class CompilerPluginsReposi
List<String> frameworkVersions = plugin.getFrameworkVersions();
List<String> coreAssemblies = plugin.getAssemblies();
String defaultAssemblyPath = plugin.getDefaultAssemblyPath();
+ String targetFramework = plugin.getTargetFramework();
List platforms = plugin.getPlatforms();
for ( Iterator j = platforms.iterator(); j.hasNext(); )
@@ -137,6 +138,7 @@ public final class CompilerPluginsReposi
platformCapability.setFrameworkVersions( frameworkVersions );
platformCapability.setProfile( profile );
platformCapability.setAssemblyPath( defaultAssemblyPath );
+ platformCapability.setTargetFramework( targetFramework );
String arch = platform.getArchitecture();
CommandFilter filter = plugin.getCommandFilter();
platformCapability.setCoreAssemblies( coreAssemblies );
Modified: incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo (original)
+++ incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo Sat Jul 9 22:59:17 2011
@@ -104,6 +104,13 @@ under the License.
<type>String</type>
</field>
<field>
+ <name>targetFramework</name>
+ <description>
+ Target framework for the compiled artifact.
+ </description>
+ <type>String</type>
+ </field>
+ <field>
<name>assemblies</name>
<description>
Assemblies to reference from the command line. This is used to create custom profiles (such as
Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
+++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Sat Jul 9 22:59:17 2011
@@ -25,6 +25,11 @@ import npanday.vendor.SettingsException;
import npanday.vendor.SettingsUtil;
import org.apache.maven.artifact.Artifact;
import npanday.PlatformUnsupportedException;
+import npanday.assembler.AssemblerContext;
+import npanday.assembler.AssemblyInfoMarshaller;
+import npanday.assembler.AssemblyInfoException;
+import npanday.assembler.AssemblyInfo;
+import npanday.assembler.AssemblyInfo.TargetFramework;
import npanday.executable.ExecutionException;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerExecutable;
@@ -35,14 +40,19 @@ import org.apache.maven.plugin.MojoExecu
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.FileWriter;
+import java.io.IOException;
import java.io.Writer;
-import java.io.FileReader;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.util.ArrayList;
import java.util.Set;
+import java.util.Arrays;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -69,6 +79,11 @@ public abstract class AbstractCompilerMo
private String settingsPath;
/**
+ * @component
+ */
+ private AssemblerContext assemblerContext;
+
+ /**
* Skips compiling of unit tests
*
* @parameter expression = "${skipTestCompile}" default-value = "false"
@@ -1106,6 +1121,8 @@ public abstract class AbstractCompilerMo
profileAssemblyPath);
if (!test)
{
+ // System.Runtime.Versioning.TargetFrameworkAttribute support
+ generateAssemblyAttributesIfNecessary(compilerExecutable.getTargetFramework());
Boolean sourceFilesUpToDate = (Boolean) super.getPluginContext().get("SOURCE_FILES_UP_TO_DATE");
if (((sourceFilesUpToDate == null) || sourceFilesUpToDate) &&
@@ -1237,4 +1254,81 @@ public abstract class AbstractCompilerMo
return lastModArtifact;
}
+ private void generateAssemblyAttributesIfNecessary(String frameworkName) throws MojoExecutionException
+ {
+ if (frameworkName != null)
+ {
+ TargetFramework targetFramework = new TargetFramework();
+ targetFramework.setFrameworkName(frameworkName);
+ //targetFramework.setFrameworkDisplayName(frameworkDisplayName);
+
+ AssemblyInfo assemblyInfo = new AssemblyInfo();
+ assemblyInfo.setTargetFramework(targetFramework);
+
+ try
+ {
+ FileInputStream assemblyAttrsInput = null;
+ FileOutputStream assemblyAttrsOutput = null;
+ try
+ {
+ String sourcesDir = project.getBuild().getDirectory() + "/build-sources";
+ String groupIdAsDir = project.getGroupId().replace( ".", File.separator );
+
+ File assemblyAttrsDir = new File( sourcesDir + "/META-INF/" + groupIdAsDir );
+ String assemblyAttrsExt = assemblerContext.getClassExtensionFor( language.trim() );
+ File assemblyAttrsFile = new File(assemblyAttrsDir, frameworkName + ".AssemblyAttributes." + assemblyAttrsExt);
+
+ ByteArrayOutputStream bytesOutput = new ByteArrayOutputStream();
+ AssemblyInfoMarshaller marshaller = assemblerContext.getAssemblyInfoMarshallerFor( language.trim() );
+ marshaller.marshal( assemblyInfo, project, bytesOutput );
+ bytesOutput.close();
+ byte[] byteArrayOutput = bytesOutput.toByteArray();
+
+ byte[] byteArrayInput = null;
+ if (assemblyAttrsFile.exists())
+ {
+ assemblyAttrsInput = new FileInputStream(assemblyAttrsFile);
+ if (assemblyAttrsInput.available() == byteArrayOutput.length)
+ {
+ byteArrayInput = new byte[byteArrayOutput.length];
+ int bytesRead = assemblyAttrsInput.read(byteArrayInput);
+ }
+ }
+
+ if (byteArrayInput == null || !Arrays.equals(byteArrayInput, byteArrayOutput))
+ {
+ assemblyAttrsDir.mkdirs();
+ assemblyAttrsOutput = new FileOutputStream(assemblyAttrsFile);
+ assemblyAttrsOutput.write(byteArrayOutput);
+ }
+
+ }
+ finally
+ {
+ if ( assemblyAttrsOutput != null )
+ {
+ assemblyAttrsOutput.close();
+ }
+
+ if ( assemblyAttrsInput != null )
+ {
+ assemblyAttrsInput.close();
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "NPANDAY-902-008: Problem generating assembly attributes class", e );
+ }
+ catch ( AssemblyInfoException e )
+ {
+ throw new MojoExecutionException( "NPANDAY-902-009: Problem generating assembly attributes class", e );
+ }
+ catch ( PlatformUnsupportedException e )
+ {
+ throw new MojoExecutionException( "NPANDAY-902-010: Problem generating assembly attributes class", e );
+ }
+ }
+ }
+
}
Modified: incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java?rev=1144760&r1=1144759&r2=1144760&view=diff
==============================================================================
--- incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java (original)
+++ incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java Sat Jul 9 22:59:17 2011
@@ -38,7 +38,6 @@ import npanday.assembler.AssemblerContex
import npanday.assembler.AssemblyInfoMarshaller;
import npanday.assembler.AssemblyInfoException;
import npanday.assembler.AssemblyInfo;
-import npanday.assembler.AssemblyInfo.TargetFramework;
/**
* Generates an AssemblyInfo.* class based on information within the pom file.
@@ -113,20 +112,6 @@ public class AssemblyInfoGeneratorMojo
private String sourceDirectory;
/**
- * The framework name to target.
- *
- * @parameter expression = "${frameworkName}"
- */
- private String frameworkName;
-
- /**
- * The framework display name to target.
- *
- * @parameter expression = "${frameworkDisplayName}"
- */
- private String frameworkDisplayName;
-
- /**
* @component
*/
private AssemblerContext assemblerContext;
@@ -156,57 +141,6 @@ public class AssemblyInfoGeneratorMojo
return;
}
-
- // auto-generate the target framework attribute metadata (needed for .NETPortable)
- if ( frameworkName != null )
- {
- TargetFramework targetFramework = new TargetFramework();
- targetFramework.setFrameworkName(frameworkName);
- targetFramework.setFrameworkDisplayName(frameworkDisplayName);
-
- AssemblyInfo assemblyInfo = new AssemblyInfo();
- assemblyInfo.setTargetFramework(targetFramework);
-
- try
- {
- FileOutputStream assemblyAttrs = null;
- try
- {
- String sourcesDir = project.getBuild().getDirectory() + "/build-sources";
- String groupIdAsDir = project.getGroupId().replace( ".", File.separator );
-
- File assemblyAttrsDir = new File( sourcesDir + "/META-INF/" + groupIdAsDir );
- String assemblyAttrsExt = assemblerContext.getClassExtensionFor( language.trim() );
-
- assemblyAttrsDir.mkdirs();
- assemblyAttrs = new FileOutputStream(
- assemblyAttrsDir + File.separator + frameworkName + ".AssemblyAttributes." + assemblyAttrsExt );
-
- AssemblyInfoMarshaller marshaller = assemblerContext.getAssemblyInfoMarshallerFor( language.trim() );
- marshaller.marshal( assemblyInfo, project, assemblyAttrs );
- }
- finally
- {
- if ( assemblyAttrs != null )
- {
- assemblyAttrs .close();
- }
- }
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "NPANDAY-902-008: Problem generating assembly attributes class", e );
- }
- catch ( AssemblyInfoException e )
- {
- throw new MojoExecutionException( "NPANDAY-902-009: Problem generating assembly attributes class", e );
- }
- catch ( PlatformUnsupportedException e )
- {
- throw new MojoExecutionException( "NPANDAY-902-010: Problem generating assembly attributes class", e );
- }
- }
-
File srcFile = new File( sourceDirectory );
if ( srcFile.exists() )
{