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 lc...@apache.org on 2011/12/12 12:16:09 UTC
svn commit: r1213206 [4/5] - in
/incubator/npanday/branches/1.5.0-azuresupport:
archetypes/maven-archetype-netexecutable/src/main/resources/archetype-resources/src/main/java/
components/ components/dotnet-artifact/src/main/java/npanday/artifact/impl/
c...
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java?rev=1213206&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/ContextAwareModelInterpolator.java Mon Dec 12 12:16:06 2011
@@ -0,0 +1,196 @@
+package npanday.registry.impl;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.Interpolator;
+import org.codehaus.plexus.interpolation.PrefixAwareRecursionInterceptor;
+import org.codehaus.plexus.interpolation.PrefixedObjectValueSource;
+import org.codehaus.plexus.interpolation.PrefixedPropertiesValueSource;
+import org.codehaus.plexus.interpolation.RecursionInterceptor;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.interpolation.object.FieldBasedObjectInterpolator;
+import org.codehaus.plexus.interpolation.object.ObjectInterpolationWarning;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Interpolates Maven Project expressions and registry lookups.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ * @plexus.component role="npanday.registry.ModelInterpolator"
+ */
+public class ContextAwareModelInterpolator
+ extends AbstractLogEnabled
+ implements npanday.registry.ModelInterpolator
+{
+ private static final Properties ENVIRONMENT_VARIABLES;
+
+ public static final List<String> PROJECT_PREFIXES;
+
+ public static final List<String> PROJECT_PROPERTIES_PREFIXES;
+
+ public static final String SETTINGS_PREFIX = "settings.";
+
+ static
+ {
+ final List<String> projectPrefixes = new ArrayList<String>();
+ projectPrefixes.add( "pom." );
+ projectPrefixes.add( "project." );
+
+ PROJECT_PREFIXES = Collections.unmodifiableList( projectPrefixes );
+
+ final List<String> projectPropertiesPrefixes = new ArrayList<String>();
+
+ projectPropertiesPrefixes.add( "pom.properties." );
+ projectPropertiesPrefixes.add( "project.properties." );
+
+ PROJECT_PROPERTIES_PREFIXES = Collections.unmodifiableList( projectPropertiesPrefixes );
+
+ Properties environmentVariables;
+ try
+ {
+ environmentVariables = CommandLineUtils.getSystemEnvVars( false );
+ }
+ catch ( final IOException e )
+ {
+ environmentVariables = new Properties();
+ }
+
+ ENVIRONMENT_VARIABLES = environmentVariables;
+ }
+
+ public <T> T interpolate( final T model, final MavenProject project ) throws InterpolationException
+ {
+ @SuppressWarnings( "unchecked" )
+ final Set<String> blacklistFields = new HashSet<String>(
+ FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_FIELD_NAMES
+ );
+
+ @SuppressWarnings( "unchecked" )
+ final Set<String> blacklistPkgs = FieldBasedObjectInterpolator.DEFAULT_BLACKLISTED_PACKAGE_PREFIXES;
+
+ final FieldBasedObjectInterpolator objectInterpolator = new FieldBasedObjectInterpolator(
+ blacklistFields, blacklistPkgs
+ );
+ final Interpolator interpolator = buildInterpolator( project );
+
+ // TODO: Will this adequately detect cycles between prefixed property references and prefixed project
+ // references??
+ final RecursionInterceptor interceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES, true );
+
+ try
+ {
+ objectInterpolator.interpolate( model, interpolator, interceptor );
+ }
+ finally
+ {
+ interpolator.clearAnswers();
+ }
+
+ if ( objectInterpolator.hasWarnings() && getLogger().isDebugEnabled() )
+ {
+ final StringBuffer sb = new StringBuffer();
+
+ sb.append( "NPANDAY-116-000: One or more minor errors occurred while interpolating the model: \n" );
+
+ @SuppressWarnings( "unchecked" )
+ final List<ObjectInterpolationWarning> warnings = objectInterpolator.getWarnings();
+ for ( final Iterator<ObjectInterpolationWarning> it = warnings.iterator(); it.hasNext(); )
+ {
+ final ObjectInterpolationWarning warning = it.next();
+
+ sb.append( '\n' ).append( warning );
+ }
+
+ sb.append( "\n\nThese values were SKIPPED, but the assembly process will continue.\n" );
+
+ getLogger().debug( sb.toString() );
+ }
+
+ return model;
+ }
+
+ public static Interpolator buildInterpolator( final MavenProject project )
+ {
+ final StringSearchInterpolator interpolator = new StringSearchInterpolator();
+ interpolator.setCacheAnswers( true );
+
+ if ( project != null )
+ {
+ interpolator.addValueSource(
+ new PrefixedPropertiesValueSource(
+ PROJECT_PROPERTIES_PREFIXES, project.getProperties(), true
+ )
+ );
+
+ interpolator.addValueSource(
+ new PrefixedObjectValueSource(
+ PROJECT_PREFIXES, project, true
+ )
+ );
+ }
+
+ /*final Properties settingsProperties = new Properties();
+ if ( session != null && session.getSettings() != null )
+ {
+ settingsProperties.setProperty( "localRepository", session.getSettings().getLocalRepository() );
+ settingsProperties.setProperty( "settings.localRepository", configSource.getLocalRepository().getBasedir
+ () );
+ }
+ interpolator.addValueSource( new PropertiesBasedValueSource( settingsProperties ) );
+
+ Properties commandLineProperties = System.getProperties();
+ if ( session != null )
+ {
+ commandLineProperties = new Properties();
+ if ( session.getExecutionProperties() != null )
+ {
+ commandLineProperties.putAll( session.getExecutionProperties() );
+ }
+
+ if ( session.getUserProperties() != null )
+ {
+ commandLineProperties.putAll( session.getUserProperties() );
+ }
+ }
+ interpolator.addValueSource( new PropertiesBasedValueSource( commandLineProperties ) );
+ */
+
+ interpolator.addValueSource(
+ new PrefixedPropertiesValueSource(
+ Collections.singletonList( "env." ), ENVIRONMENT_VARIABLES, true
+ )
+ );
+ interpolator.addValueSource( new WindowsRegistryValueSource( new WinRegistry() ) );
+
+ return interpolator;
+ }
+}
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java?rev=1213206&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WinRegistry.java Mon Dec 12 12:16:06 2011
@@ -0,0 +1,510 @@
+package npanday.registry.impl;
+
+import npanday.registry.WindowsRegistryAccessException;
+import npanday.registry.WindowsRegistryAccessProvider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.prefs.Preferences;
+
+public class WinRegistry
+ implements WindowsRegistryAccessProvider
+{
+ public static final int HKEY_CURRENT_USER = 0x80000001;
+
+ public static final int HKEY_LOCAL_MACHINE = 0x80000002;
+
+ public static final int REG_SUCCESS = 0;
+
+ private static final int KEY_ALL_ACCESS = 0xf003f;
+
+ private static final int KEY_READ = 0x20019;
+
+ private static Preferences userRoot = Preferences.userRoot();
+
+ private static Preferences systemRoot = Preferences.systemRoot();
+
+ private static Class<? extends Preferences> userClass = userRoot.getClass();
+
+ private static Method regOpenKey = null;
+
+ private static Method regCloseKey = null;
+
+ private static Method regQueryValueEx = null;
+
+ private static Method regEnumValue = null;
+
+ private static Method regQueryInfoKey = null;
+
+ private static Method regEnumKeyEx = null;
+
+ private static Method regCreateKeyEx = null;
+
+ private static Method regSetValueEx = null;
+
+ private static Method regDeleteKey = null;
+
+ private static Method regDeleteValue = null;
+
+ static
+ {
+ try
+ {
+ regOpenKey = userClass.getDeclaredMethod(
+ "WindowsRegOpenKey", new Class[]{ int.class, byte[].class, int.class }
+ );
+ regOpenKey.setAccessible( true );
+ regCloseKey = userClass.getDeclaredMethod( "WindowsRegCloseKey", new Class[]{ int.class } );
+ regCloseKey.setAccessible( true );
+ regQueryValueEx = userClass.getDeclaredMethod(
+ "WindowsRegQueryValueEx", new Class[]{ int.class, byte[].class }
+ );
+ regQueryValueEx.setAccessible( true );
+ regEnumValue = userClass.getDeclaredMethod(
+ "WindowsRegEnumValue", new Class[]{ int.class, int.class, int.class }
+ );
+ regEnumValue.setAccessible( true );
+ regQueryInfoKey = userClass.getDeclaredMethod( "WindowsRegQueryInfoKey1", new Class[]{ int.class } );
+ regQueryInfoKey.setAccessible( true );
+ regEnumKeyEx = userClass.getDeclaredMethod(
+ "WindowsRegEnumKeyEx", new Class[]{ int.class, int.class, int.class }
+ );
+ regEnumKeyEx.setAccessible( true );
+ regCreateKeyEx = userClass.getDeclaredMethod(
+ "WindowsRegCreateKeyEx", new Class[]{ int.class, byte[].class }
+ );
+ regCreateKeyEx.setAccessible( true );
+ regSetValueEx = userClass.getDeclaredMethod(
+ "WindowsRegSetValueEx", new Class[]{ int.class, byte[].class, byte[].class }
+ );
+ regSetValueEx.setAccessible( true );
+ regDeleteValue = userClass.getDeclaredMethod(
+ "WindowsRegDeleteValue", new Class[]{ int.class, byte[].class }
+ );
+ regDeleteValue.setAccessible( true );
+ regDeleteKey = userClass.getDeclaredMethod(
+ "WindowsRegDeleteKey", new Class[]{
+ int.class, byte[].class
+ }
+ );
+ regDeleteKey.setAccessible( true );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public WinRegistry()
+ {
+ }
+
+ /**
+ * Read a value from key and value name
+ *
+ * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+ * @param key
+ * @param valueName
+ * @return the value
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static String readString( int hkey, String key, String valueName ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ return readString( systemRoot, hkey, key, valueName );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ return readString( userRoot, hkey, key, valueName );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "hkey=" + hkey );
+ }
+ }
+
+ /**
+ * Read value(s) and value name(s) form given key
+ *
+ * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+ * @param key
+ * @return the value name(s) plus the value(s)
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static Map<String, String> readStringValues( int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ return readStringValues( systemRoot, hkey, key );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ return readStringValues( userRoot, hkey, key );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "hkey=" + hkey );
+ }
+ }
+
+ /**
+ * Read the value name(s) from a given key
+ *
+ * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+ * @param key
+ * @return the value name(s)
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static List<String> readStringSubKeys( int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ return readStringSubKeys( systemRoot, hkey, key );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ return readStringSubKeys( userRoot, hkey, key );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "hkey=" + hkey );
+ }
+ }
+
+ /**
+ * Create a key
+ *
+ * @param hkey HKEY_CURRENT_USER/HKEY_LOCAL_MACHINE
+ * @param key
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static void createKey( int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int[] ret;
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ ret = createKey( systemRoot, hkey, key );
+ regCloseKey.invoke( systemRoot, new Object[]{ new Integer( ret[0] ) } );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ ret = createKey( userRoot, hkey, key );
+ regCloseKey.invoke( userRoot, new Object[]{ new Integer( ret[0] ) } );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "hkey=" + hkey );
+ }
+ if ( ret[1] != REG_SUCCESS )
+ {
+ throw new IllegalArgumentException( "rc=" + ret[1] + " key=" + key );
+ }
+ }
+
+ /**
+ * Write a value in a given key/value name
+ *
+ * @param hkey
+ * @param key
+ * @param valueName
+ * @param value
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static void writeStringValue( int hkey, String key, String valueName, String value ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ writeStringValue( systemRoot, hkey, key, valueName, value );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ writeStringValue( userRoot, hkey, key, valueName, value );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "hkey=" + hkey );
+ }
+ }
+
+ /**
+ * Delete a given key
+ *
+ * @param hkey
+ * @param key
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static void deleteKey( int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int rc = -1;
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ rc = deleteKey( systemRoot, hkey, key );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ rc = deleteKey( userRoot, hkey, key );
+ }
+ if ( rc != REG_SUCCESS )
+ {
+ throw new IllegalArgumentException( "rc=" + rc + " key=" + key );
+ }
+ }
+
+ /**
+ * delete a value from a given key/value name
+ *
+ * @param hkey
+ * @param key
+ * @param value
+ * @throws IllegalArgumentException
+ * @throws IllegalAccessException
+ * @throws java.lang.reflect.InvocationTargetException
+ *
+ */
+ public static void deleteValue( int hkey, String key, String value ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int rc = -1;
+ if ( hkey == HKEY_LOCAL_MACHINE )
+ {
+ rc = deleteValue( systemRoot, hkey, key, value );
+ }
+ else if ( hkey == HKEY_CURRENT_USER )
+ {
+ rc = deleteValue( userRoot, hkey, key, value );
+ }
+ if ( rc != REG_SUCCESS )
+ {
+ throw new IllegalArgumentException( "rc=" + rc + " key=" + key + " value=" + value );
+ }
+ }
+
+ // =====================
+
+ private static int deleteValue( Preferences root, int hkey, String key, String value ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int[] handles = (int[]) regOpenKey.invoke(
+ root, new Object[]{
+ new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
+ }
+ );
+ if ( handles[1] != REG_SUCCESS )
+ {
+ return handles[1]; // can be REG_NOTFOUND, REG_ACCESSDENIED
+ }
+ int rc = (
+ (Integer) regDeleteValue.invoke(
+ root, new Object[]{
+ new Integer( handles[0] ), toCstr( value )
+ }
+ )
+ ).intValue();
+ regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+ return rc;
+ }
+
+ private static int deleteKey( Preferences root, int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int rc = (
+ (Integer) regDeleteKey.invoke(
+ root, new Object[]{ new Integer( hkey ), toCstr( key ) }
+ )
+ ).intValue();
+ return rc; // can REG_NOTFOUND, REG_ACCESSDENIED, REG_SUCCESS
+ }
+
+ private static String readString( Preferences root, int hkey, String key, String value ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int[] handles = (int[]) regOpenKey.invoke(
+ root, new Object[]{
+ new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+ }
+ );
+ if ( handles[1] != REG_SUCCESS )
+ {
+ return null;
+ }
+ byte[] valb = (byte[]) regQueryValueEx.invoke(
+ root, new Object[]{ new Integer( handles[0] ), toCstr( value ) }
+ );
+ regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+ return ( valb != null ? new String( valb ).trim() : null );
+ }
+
+ private static Map<String, String> readStringValues( Preferences root, int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ HashMap<String, String> results = new HashMap<String, String>();
+ int[] handles = (int[]) regOpenKey.invoke(
+ root, new Object[]{
+ new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+ }
+ );
+ if ( handles[1] != REG_SUCCESS )
+ {
+ return null;
+ }
+ int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+
+ int count = info[2]; // count
+ int maxlen = info[3]; // value length max
+ for ( int index = 0; index < count; index++ )
+ {
+ byte[] name = (byte[]) regEnumValue.invoke(
+ root, new Object[]{
+ new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
+ }
+ );
+ String value = readString( hkey, key, new String( name ) );
+ results.put( new String( name ).trim(), value );
+ }
+ regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+ return results;
+ }
+
+ private static List<String> readStringSubKeys( Preferences root, int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ List<String> results = new ArrayList<String>();
+ int[] handles = (int[]) regOpenKey.invoke(
+ root, new Object[]{
+ new Integer( hkey ), toCstr( key ), new Integer( KEY_READ )
+ }
+ );
+ if ( handles[1] != REG_SUCCESS )
+ {
+ return null;
+ }
+ int[] info = (int[]) regQueryInfoKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+
+ int count = info[2]; // count
+ int maxlen = info[3]; // value length max
+ for ( int index = 0; index < count; index++ )
+ {
+ byte[] name = (byte[]) regEnumKeyEx.invoke(
+ root, new Object[]{
+ new Integer( handles[0] ), new Integer( index ), new Integer( maxlen + 1 )
+ }
+ );
+ results.add( new String( name ).trim() );
+ }
+ regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+ return results;
+ }
+
+ private static int[] createKey( Preferences root, int hkey, String key ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ return (int[]) regCreateKeyEx.invoke( root, new Object[]{ new Integer( hkey ), toCstr( key ) } );
+ }
+
+ private static void writeStringValue(
+ Preferences root, int hkey, String key, String valueName, String value ) throws
+ IllegalArgumentException,
+ IllegalAccessException,
+ InvocationTargetException
+ {
+ int[] handles = (int[]) regOpenKey.invoke(
+ root, new Object[]{
+ new Integer( hkey ), toCstr( key ), new Integer( KEY_ALL_ACCESS )
+ }
+ );
+
+ regSetValueEx.invoke( root, new Object[]{ new Integer( handles[0] ), toCstr( valueName ), toCstr( value ) } );
+ regCloseKey.invoke( root, new Object[]{ new Integer( handles[0] ) } );
+ }
+
+ // utility
+ private static byte[] toCstr( String str )
+ {
+ byte[] result = new byte[str.length() + 1];
+
+ for ( int i = 0; i < str.length(); i++ )
+ {
+ result[i] = (byte) str.charAt( i );
+ }
+ result[str.length()] = 0;
+ return result;
+ }
+
+ public String getValue(
+ RegistryHKey registryHKey, String key, String valueName ) throws WindowsRegistryAccessException
+ {
+ try
+ {
+ return WinRegistry.readString(
+ registryHKey.getHKey(), key, valueName
+ );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new WindowsRegistryAccessException(
+ "NPANDAY-117-000: Error while retrieving a windows registry value", e
+ );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new WindowsRegistryAccessException(
+ "NPANDAY-117-001: Error while retrieving a windows registry value", e
+ );
+ }
+ }
+}
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java?rev=1213206&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/main/java/npanday/registry/impl/WindowsRegistryValueSource.java Mon Dec 12 12:16:06 2011
@@ -0,0 +1,63 @@
+package npanday.registry.impl;
+
+import hidden.org.codehaus.plexus.interpolation.AbstractValueSource;
+import npanday.registry.WindowsRegistryAccessException;
+import npanday.registry.WindowsRegistryAccessProvider;
+import org.codehaus.plexus.interpolation.ValueSource;
+
+/**
+ * Tries to find registry settings for all expressions starting with HKLM or HKCU.
+ *
+ * @author <a href="mailto:lcorneliussen@apache.org">Lars Corneliussen</a>
+ */
+public class WindowsRegistryValueSource
+ extends AbstractValueSource
+ implements ValueSource
+{
+ private WindowsRegistryAccessProvider registry;
+
+ public WindowsRegistryValueSource( WindowsRegistryAccessProvider registry )
+ {
+ super( true );
+ this.registry = registry;
+ }
+
+ public Object getValue( String expression )
+ {
+ int indexOfBackslash = expression.indexOf( "\\" );
+ if (indexOfBackslash == -1)
+ return null;
+
+ String hkeyExpression = expression.substring( 0, indexOfBackslash );
+
+ final WindowsRegistryAccessProvider.RegistryHKey registryHKey = WindowsRegistryAccessProvider.RegistryHKey
+ .tryGetFromName(
+ hkeyExpression
+ );
+
+ if (registryHKey == null)
+ return null;
+
+ if (expression.length() < indexOfBackslash || !expression.contains( "@" ))
+ return null;
+
+ String keyAndValueNamePart = expression.substring( indexOfBackslash +1 );
+ int indexOfAt = keyAndValueNamePart.indexOf( '@' );
+
+ String key = keyAndValueNamePart.substring( 0, indexOfAt );
+ String valueName = keyAndValueNamePart.substring( indexOfAt+1 );
+
+ try
+ {
+ final String value = registry.getValue( registryHKey, key, valueName );
+ addFeedback( "NPANDAY-118-001: Retrieved the registry value for " + expression + ": " + value);
+ return value;
+ }
+ catch ( WindowsRegistryAccessException e )
+ {
+ addFeedback( "NPANDAY-118-000: Could not retrieve the registry value for " + expression, e );
+ return null;
+ }
+ }
+}
+
Added: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy?rev=1213206&view=auto
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy (added)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-registry/src/test/groovy/WindowsRegistryValueSourceTest.groovy Mon Dec 12 12:16:06 2011
@@ -0,0 +1,55 @@
+/* Copyright 2010 NPanday
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * 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 npanday.registry.impl
+
+import npanday.registry.WindowsRegistryAccessException
+import npanday.registry.WindowsRegistryAccessProvider
+import npanday.registry.WindowsRegistryAccessProvider.RegistryHKey
+import org.gmock.GMockTestCase
+import org.junit.Test
+
+class WindowsRegistryValueSourceTest extends GMockTestCase
+{
+ @Test
+ void testExceptionIsCaught()
+ {
+ def provider = mock(WindowsRegistryAccessProvider);
+
+ provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").raises(new WindowsRegistryAccessException("Trouble here!!"))
+
+ play{
+ def source = new WindowsRegistryValueSource(provider)
+
+ assert source.getValue("HKLM\\Key@ValueName") == null
+ }
+ }
+
+ @Test
+ void testExpressionParsing()
+ {
+ def provider = mock(WindowsRegistryAccessProvider);
+
+ provider.getValue(RegistryHKey.HKLM, "Key", "ValueName").returns("value")
+
+ play{
+ def source = new WindowsRegistryValueSource(provider)
+
+ assert source.getValue("HKLM\\Key@ValueName") == "value"
+ }
+ }
+}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorInfo.java Mon Dec 12 12:16:06 2011
@@ -18,7 +18,7 @@
*/
package npanday.vendor;
-import npanday.vendor.impl.MutableVendorInfo;
+import npanday.PlatformUnsupportedException;
import java.io.File;
import java.util.List;
@@ -74,20 +74,14 @@ public interface VendorInfo
File getInstallRoot();
+ File getGlobalAssemblyCacheDirectoryFor( String artifactType )
+ throws PlatformUnsupportedException;
+
/**
* Provides factory services for creating a default instance of vendor info.
*/
public static class Factory
{
- /**
- * Creates a mutable implementation of vendor info.
- *
- * @return a default implementation of vendor info
- */
- public static MutableVendorInfo createDefaultVendorInfo()
- {
- return new MutableVendorInfo();
- }
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/VendorRequirement.java Mon Dec 12 12:16:06 2011
@@ -19,10 +19,7 @@ public class VendorRequirement
public VendorRequirement( String vendorName, String vendorVersion, String frameworkVersion )
{
- if (!isNullOrEmpty(vendorName))
- {
- setVendor( VendorFactory.createVendorFromName( vendorName ) );
- }
+ setVendor( vendorName );
setVendorVersion( vendorVersion );
setFrameworkVersion( frameworkVersion );
}
@@ -51,6 +48,17 @@ public class VendorRequirement
}
/**
+ * @see npanday.vendor.VendorInfo#getVendor()
+ */
+ public void setVendor( String vendorName )
+ {
+ if (!isNullOrEmpty(vendorName))
+ {
+ setVendor( VendorFactory.createVendorFromName( vendorName ) );
+ }
+ }
+
+ /**
* @see npanday.vendor.VendorInfo#getVendorVersion()
*/
public String getVendorVersion()
@@ -105,7 +113,7 @@ public class VendorRequirement
public String toString()
{
- return "[Vendor Requirement for vendor " + visibleNullString( vendor ) + " version "
+ return "[" + getClass().getSimpleName() + " for vendor " + visibleNullString( vendor ) + " version "
+ visibleNullString(getVendorVersion()) + ", Framework Version = "
+ visibleNullString(getFrameworkVersion()) + "]";
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/FileBasedSettingsRepository.java Mon Dec 12 12:16:06 2011
@@ -24,9 +24,11 @@ import npanday.model.settings.Framework;
import npanday.model.settings.NPandaySettings;
import npanday.model.settings.Vendor;
import npanday.model.settings.io.xpp3.NPandaySettingsXpp3Reader;
+import npanday.registry.ModelInterpolator;
import npanday.registry.NPandayRepositoryException;
import npanday.registry.impl.AbstractMultisourceRepository;
import npanday.vendor.SettingsRepository;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -205,5 +207,18 @@ public final class FileBasedSettingsRepo
{
}
+
+ // ### COMPONENTS REQUIRED BY THE BASE CLASS
+
+ /**
+ * @plexus.requirement
+ */
+ private ModelInterpolator interpolator;
+
+ @Override
+ protected ModelInterpolator getInterpolator()
+ {
+ return interpolator;
+ }
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsBasedVendorInfo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsBasedVendorInfo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsBasedVendorInfo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/SettingsBasedVendorInfo.java Mon Dec 12 12:16:06 2011
@@ -3,6 +3,9 @@ package npanday.vendor.impl;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import npanday.ArtifactType;
+import npanday.ArtifactTypeHelper;
+import npanday.PlatformUnsupportedException;
import npanday.model.settings.Framework;
import npanday.vendor.Vendor;
import npanday.vendor.VendorFactory;
@@ -86,6 +89,124 @@ public class SettingsBasedVendorInfo
return new File(configuredFramework.getInstallRoot());
}
+ // TODO: Move this to a composed type: GacFinderStrategy
+ public File getGlobalAssemblyCacheDirectoryFor( String artifactType )
+ throws PlatformUnsupportedException
+ {
+ if (!ArtifactTypeHelper.isDotnetAnyGac( artifactType ))
+ return null;
+
+ if ( ArtifactTypeHelper.isDotnetGenericGac( artifactType ))
+ {
+ if ( vendor.equals( Vendor.MICROSOFT ) && getFrameworkVersion().equals( "1.1.4322" ) )
+ {
+ return new File( System.getenv("SystemRoot"), "\\assembly\\GAC\\" );
+ }
+ else if ( vendor.equals( Vendor.MICROSOFT ) )
+ {
+ // Layout changed since 2.0
+ // http://discuss.joelonsoftware.com/default.asp?dotnet.12.383883.5
+ return new File( System.getenv("SystemRoot"), "\\assembly\\GAC_MSIL\\" );
+ }
+ // TODO: fully implement finder for generic gac-type - better configure it somehow!
+ else if ( vendor.equals( Vendor.MONO ) )
+ {
+ return getGacRootForMono();
+ }
+ }
+ else if ( artifactType.equals( ArtifactType.GAC.getPackagingType() ) )
+ {
+ return new File( System.getenv("SystemRoot"), "\\assembly\\GAC\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_32.getPackagingType() ) )
+ {
+ return new File(System.getenv("SystemRoot"), "\\assembly\\GAC_32\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_32_4.getPackagingType() ) )
+ {
+ return new File(System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_32\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_64.getPackagingType() ) )
+ {
+ return new File(System.getenv("SystemRoot"), "\\assembly\\GAC_64\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_64_4.getPackagingType() ) )
+ {
+ return new File(System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_64\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_MSIL.getPackagingType() ) )
+ {
+ return new File( System.getenv("SystemRoot"), "\\assembly\\GAC_MSIL\\" );
+ }
+ else if ( artifactType.equals( ArtifactType.GAC_MSIL4.getPackagingType() ) )
+ {
+ return new File( System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_MSIL\\" );
+ }
+ throw new PlatformUnsupportedException("NPANDAY-113-006: Could not locate a valid GAC");
+ }
+
+ private File getGacRootForMono()
+ throws PlatformUnsupportedException
+ {
+ // TODO: Multiple implemenations for finding mono gac...
+ /*
+ Found this somewhere...
+
+ File sdkInstallRoot = getSdkInstallRoot();
+ File gacRoot = new File( getSdkInstallRoot().getParentFile().getAbsolutePath() + "/lib/mono/gac" );
+ if ( !gacRoot.exists() )
+ {
+ throw new PlatformUnsupportedException(
+ "NPANDAY-113-005: The Mono GAC path does not exist: Path = " +
+ gacRoot.getAbsolutePath() );
+
+ }
+ return gacRoot;
+
+ */
+
+ String path = System.getenv( "PATH" );
+ if ( path != null )
+ {
+ String[] tokens = path.split( System.getProperty( "path.separator" ) );
+ for ( String token : tokens )
+ {
+ File gacRoot = new File( new File( token ).getParentFile(), "lib/mono/gac/" );
+ if ( gacRoot.exists() )
+ {
+ return gacRoot;
+ }
+ }
+ }
+ //check settings file
+
+ String monoRoot = System.getenv( "MONO_ROOT" );
+ if ( monoRoot != null && !new File( monoRoot ).exists() )
+ {
+ // getLogger().warn( "MONO_ROOT has been incorrectly set. Trying /usr : MONO_ROOT = " + monoRoot );
+ }
+ else if ( monoRoot != null )
+ {
+ return new File(( !monoRoot.endsWith( File.separator ) ) ? monoRoot + File.separator : monoRoot);
+ }
+
+ if ( new File( "/usr/lib/mono/gac/" ).exists() )
+ {
+ // Linux default location
+ return new File( "/usr/lib/mono/gac/" );
+ }
+ else if ( new File( "/Library/Frameworks/Mono.framework/Home/lib/mono/gac/" ).exists() )
+ {
+ // Mac OS X default location
+ return new File( "/Library/Frameworks/Mono.framework/Home/lib/mono/gac/" );
+ }
+ else
+ {
+ throw new PlatformUnsupportedException(
+ "NPANDAY-061-008: Could not locate Global Assembly Cache for Mono. Try setting the MONO_ROOT environmental variable." );
+ }
+ }
+
public Vendor getVendor()
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/StateMachineProcessorImpl.java Mon Dec 12 12:16:06 2011
@@ -19,6 +19,8 @@
package npanday.vendor.impl;
import npanday.PlatformUnsupportedException;
+import npanday.model.settings.Framework;
+import npanday.model.settings.Vendor;
import npanday.registry.RepositoryRegistry;
import npanday.vendor.IllegalStateException;
import npanday.vendor.SettingsException;
@@ -157,8 +159,14 @@ public final class StateMachineProcessor
// TODO: Remove this blcok, as soon as vendor discovery is moved to java code
if ( vendorInfoRepository.isEmpty() )
{
- final MutableVendorInfo vendorInfo =
- new MutableVendorInfo( VendorFactory.getDefaultVendorForOS(), "2.0", "2.0.50727" );
+ Vendor configuredVendor = new Vendor();
+ configuredVendor.setVendorName( VendorFactory.getDefaultVendorForOS().getVendorName() );
+ configuredVendor.setVendorVersion( "2.0" );
+
+ Framework configuredFramework = new Framework();
+ configuredFramework.setFrameworkVersion( "2.0.50727" );
+
+ VendorInfo vendorInfo = new SettingsBasedVendorInfo( configuredVendor, configuredFramework );
logger.warn( "NPANDAY-102-006: Chose sensible default, because there are no settings available yet:"
+ vendorInfo );
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/VendorInfoRepositoryImpl.java Mon Dec 12 12:16:06 2011
@@ -18,8 +18,6 @@
*/
package npanday.vendor.impl;
-import npanday.ArtifactType;
-import npanday.ArtifactTypeHelper;
import npanday.PlatformUnsupportedException;
import npanday.model.settings.Framework;
import npanday.registry.RepositoryRegistry;
@@ -36,7 +34,6 @@ import org.codehaus.plexus.logging.Logge
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -233,87 +230,8 @@ public class VendorInfoRepositoryImpl
public File getGlobalAssemblyCacheDirectoryFor( Vendor vendor, String frameworkVersion, String artifactType )
throws PlatformUnsupportedException
{
- // TODO: Duplicate code with CompilerContextImpl.init
-
- if (ArtifactTypeHelper.isDotnetGenericGac( artifactType ))
- {
- if ( vendor.equals( Vendor.MICROSOFT ) && frameworkVersion.equals( "1.1.4322" ) )
- {
- return new File( System.getenv("SystemRoot"), "\\assembly\\GAC\\" );
- }
- else if ( vendor.equals( Vendor.MICROSOFT ) )
- {
- // Layout changed since 2.0
- // http://discuss.joelonsoftware.com/default.asp?dotnet.12.383883.5
- return new File( System.getenv("SystemRoot"), "\\assembly\\GAC_MSIL\\" );
- }
- else if ( vendor.equals( Vendor.MONO ) && !isEmpty() )
- {
- List<VendorInfo> vendorInfos =
- getVendorInfosFor( vendor.getVendorName(), null, frameworkVersion, true );
- Set<String> vendorVersions = new HashSet<String>();
- for ( VendorInfo vendorInfo : vendorInfos )
- {
- vendorVersions.add( vendorInfo.getVendorVersion() );
- }
- String maxVersion;
- try
- {
- maxVersion = getMaxVersion( vendorVersions );
- }
- catch ( InvalidVersionFormatException e )
- {
- throw new PlatformUnsupportedException( "NPANDAY-113-004: Invalid version format", e );
- }
-
- for ( VendorInfo vendorInfo : vendorInfos )
- {
- if ( vendorInfo.getVendorVersion().equals( maxVersion ) )
- {
- File sdkInstallRoot = vendorInfo.getSdkInstallRoot();
- File gacRoot = new File( sdkInstallRoot.getParentFile().getAbsolutePath() + "/lib/mono/gac" );
- if ( !gacRoot.exists() )
- {
- throw new PlatformUnsupportedException(
- "NPANDAY-113-005: The Mono GAC path does not exist: Path = " +
- gacRoot.getAbsolutePath() );
- }
- return gacRoot;
- }
- }
-
- //TODO: MONO Support for Linux (Separate file containg installs)
- }
- }
- else if ( artifactType.equals( ArtifactType.GAC.getPackagingType() ) )
- {
- return new File( System.getenv("SystemRoot"), "\\assembly\\GAC\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_32.getPackagingType() ) )
- {
- return new File(System.getenv("SystemRoot"), "\\assembly\\GAC_32\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_32_4.getPackagingType() ) )
- {
- return new File(System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_32\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_64.getPackagingType() ) )
- {
- return new File(System.getenv("SystemRoot"), "\\assembly\\GAC_64\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_64_4.getPackagingType() ) )
- {
- return new File(System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_64\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_MSIL.getPackagingType() ) )
- {
- return new File( System.getenv("SystemRoot"), "\\assembly\\GAC_MSIL\\" );
- }
- else if ( artifactType.equals( ArtifactType.GAC_MSIL4.getPackagingType() ) )
- {
- return new File( System.getenv("SystemRoot"), "\\Microsoft.NET\\assembly\\GAC_MSIL\\" );
- }
- throw new PlatformUnsupportedException("NPANDAY-113-006: Could not locate a valid GAC");
+ return getSingleVendorInfoByRequirement( new VendorRequirement( vendor, null, frameworkVersion ) )
+ .getGlobalAssemblyCacheDirectoryFor(artifactType);
}
public boolean isEmpty()
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MatchPolicyFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MatchPolicyFactoryTest.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MatchPolicyFactoryTest.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MatchPolicyFactoryTest.java Mon Dec 12 12:16:06 2011
@@ -22,7 +22,6 @@ import junit.framework.TestCase;
import org.codehaus.plexus.logging.console.ConsoleLogger;
import org.codehaus.plexus.logging.Logger;
import npanday.vendor.VendorInfoMatchPolicy;
-import npanday.vendor.VendorInfo;
import npanday.vendor.VendorTestFactory;
import npanday.vendor.Vendor;
@@ -83,7 +82,7 @@ public class MatchPolicyFactoryTest
public void testCreateIsDefaultPolicy_False()
{
VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorIsDefaultPolicy();
- MutableVendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
+ MutableVendorInfo vendorInfo = new MutableVendorInfo();
vendorInfo.setDefault( false );
assertFalse( matchPolicy.match( vendorInfo ) );
}
@@ -91,7 +90,7 @@ public class MatchPolicyFactoryTest
public void testCreateIsDefaultPolicy_True()
{
VendorInfoMatchPolicy matchPolicy = matchPolicyFactory.createVendorIsDefaultPolicy();
- MutableVendorInfo vendorInfo = VendorInfo.Factory.createDefaultVendorInfo();
+ MutableVendorInfo vendorInfo = new MutableVendorInfo();
vendorInfo.setDefault( true );
assertTrue( matchPolicy.match( vendorInfo ) );
}
Copied: incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MutableVendorInfo.java (from r1211347, incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/MutableVendorInfo.java)
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MutableVendorInfo.java?p2=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MutableVendorInfo.java&p1=incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/MutableVendorInfo.java&r1=1211347&r2=1213206&rev=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/main/java/npanday/vendor/impl/MutableVendorInfo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/dotnet-vendor/src/test/java/npanday/vendor/impl/MutableVendorInfo.java Mon Dec 12 12:16:06 2011
@@ -1,5 +1,6 @@
package npanday.vendor.impl;
+import npanday.PlatformUnsupportedException;
import npanday.vendor.Vendor;
import npanday.vendor.VendorInfo;
@@ -101,6 +102,12 @@ public class MutableVendorInfo
return installRoot;
}
+ public File getGlobalAssemblyCacheDirectoryFor( String artifactType )
+ throws PlatformUnsupportedException
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
public void setInstallRoot( File installRoot )
{
this.installRoot = installRoot;
Modified: incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/components/pom.xml Mon Dec 12 12:16:06 2011
@@ -54,6 +54,12 @@ under the License.
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.gmock</groupId>
+ <artifactId>gmock</artifactId>
+ <version>0.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.7.0</version>
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java Mon Dec 12 12:16:06 2011
@@ -28,7 +28,6 @@ import npanday.executable.compiler.Compi
import npanday.registry.RepositoryRegistry;
import npanday.vendor.SettingsException;
import npanday.vendor.SettingsUtil;
-import npanday.vendor.VendorFactory;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -217,8 +216,7 @@ public class AspxCompilerMojo
try
{
CompilerExecutable compilerExecutable =
- netExecutableFactory.getCompilerExecutableFor( compilerRequirement, compilerConfig, project,
- profileAssemblyPath );
+ netExecutableFactory.getCompilerExecutableFor( compilerRequirement, compilerConfig, project );
long startTimeCompile = System.currentTimeMillis();
compilerExecutable.execute();
@@ -352,7 +350,7 @@ public class AspxCompilerMojo
private CompilerConfig createCompilerConfig(String source, String destination) throws MojoExecutionException
{
- CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig();
+ CompilerConfig compilerConfig = new CompilerConfig();
compilerConfig.setLocalRepository( localRepository );
compilerConfig.setCommands( getCommands( source, destination ) );
@@ -365,22 +363,17 @@ public class AspxCompilerMojo
}
compilerConfig.setArtifactType( artifactType );
+ if (profileAssemblyPath != null){
+ compilerConfig.setAssemblyPath( profileAssemblyPath );
+ }
+
return compilerConfig;
}
private CompilerRequirement createCompilerRequirement() throws MojoExecutionException
{
- CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement();
- compilerRequirement.setLanguage( language );
- compilerRequirement.setFrameworkVersion( frameworkVersion );
- compilerRequirement.setProfile( profile );
- compilerRequirement.setVendorVersion( vendorVersion );
- if ( vendor != null )
- {
- compilerRequirement.setVendor( VendorFactory.createVendorFromName( vendor ) );
- }
-
- return compilerRequirement;
+ return new CompilerRequirement(
+ vendor, vendorVersion, frameworkVersion, profile, language);
}
private List<String> getCommands( String sourceDir, String outputDir )
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java Mon Dec 12 12:16:06 2011
@@ -1131,8 +1131,7 @@ public abstract class AbstractCompilerMo
{
CompilerExecutable compilerExecutable = netExecutableFactory.getCompilerExecutableFor(getCompilerRequirement(),
getCompilerConfig(),
- project,
- profileAssemblyPath);
+ project);
File compiledArtifact = compilerExecutable.getCompiledArtifact();
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/CompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/CompilerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/CompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/CompilerMojo.java Mon Dec 12 12:16:06 2011
@@ -18,22 +18,14 @@
*/
package npanday.plugin.compile;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.AbstractMojo;
-
-import org.apache.maven.project.MavenProject;
-import npanday.PlatformUnsupportedException;
import npanday.ArtifactType;
-import npanday.executable.ExecutionException;
-import npanday.vendor.VendorFactory;
-import npanday.executable.compiler.*;
-import org.apache.maven.artifact.Artifact;
-import org.codehaus.plexus.util.FileUtils;
+import npanday.executable.compiler.CompilerConfig;
+import npanday.executable.compiler.CompilerRequirement;
+import npanday.executable.compiler.KeyInfo;
+import org.apache.maven.plugin.MojoExecutionException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
import java.io.File;
+import java.util.ArrayList;
/**
* Maven Mojo for compiling Class files to the .NET Intermediate Language.
@@ -66,31 +58,17 @@ public final class CompilerMojo
}
-
-
-
-
-
-
-
protected CompilerRequirement getCompilerRequirement() throws MojoExecutionException
{
- //Requirement
- CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement();
- compilerRequirement.setLanguage( language );
- compilerRequirement.setFrameworkVersion( frameworkVersion );
- compilerRequirement.setProfile( profile );
- compilerRequirement.setVendorVersion( vendorVersion );
- compilerRequirement.setVendor(vendor);
-
- return compilerRequirement;
+ return new CompilerRequirement(
+ vendor, vendorVersion, frameworkVersion, profile, language);
}
protected CompilerConfig getCompilerConfig() throws MojoExecutionException
{
//Config
- CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig();
+ CompilerConfig compilerConfig = new CompilerConfig();
compilerConfig.setLocalRepository( localRepository );
@@ -137,6 +115,9 @@ public final class CompilerMojo
}
compilerConfig.setArtifactType( artifactType );
+ if (profileAssemblyPath != null){
+ compilerConfig.setAssemblyPath( profileAssemblyPath );
+ }
return compilerConfig;
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/TestCompilerMojo.java Mon Dec 12 12:16:06 2011
@@ -23,7 +23,6 @@ import npanday.ArtifactType;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerRequirement;
import npanday.executable.compiler.KeyInfo;
-import npanday.vendor.VendorFactory;
import org.apache.maven.plugin.MojoExecutionException;
import java.io.File;
@@ -91,26 +90,15 @@ public final class TestCompilerMojo
protected CompilerRequirement getCompilerRequirement() throws MojoExecutionException
{
- //Requirement
- CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement();
- compilerRequirement.setLanguage( testLanguage );
- compilerRequirement.setFrameworkVersion( testFrameworkVersion );
- compilerRequirement.setProfile( "FULL" );
- compilerRequirement.setVendorVersion( testVendorVersion );
- if ( vendor != null )
- {
- compilerRequirement.setVendor( VendorFactory.createVendorFromName( vendor ) );
- }
-
- return compilerRequirement;
-
+ return new CompilerRequirement(
+ testVendor, testVendorVersion, testFrameworkVersion, "FULL", testLanguage);
}
protected CompilerConfig getCompilerConfig() throws MojoExecutionException
{
//Config
- CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig();
+ CompilerConfig compilerConfig = new CompilerConfig();
compilerConfig.setCommands( getParameters() );
@@ -146,6 +134,9 @@ public final class TestCompilerMojo
}
+ if (profileAssemblyPath != null){
+ compilerConfig.setAssemblyPath( profileAssemblyPath );
+ }
return compilerConfig;
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopAggregateMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopAggregateMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopAggregateMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopAggregateMojo.java Mon Dec 12 12:16:06 2011
@@ -22,6 +22,7 @@ import npanday.ArtifactType;
import npanday.PlatformUnsupportedException;
import npanday.artifact.AssemblyResolver;
import npanday.artifact.NPandayArtifactResolutionException;
+import npanday.executable.ExecutableRequirement;
import npanday.executable.ExecutionException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -155,8 +156,7 @@ public class FxCopAggregateMojo
try
{
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, profile, getCommands(),
- null ).execute();
+ netExecutableFactory.getNetExecutableFor( new ExecutableRequirement( vendor, null, frameworkVersion, profile ), getCommands(), null ).execute();
}
catch ( ExecutionException e )
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopMojo.java Mon Dec 12 12:16:06 2011
@@ -18,23 +18,24 @@
*/
package npanday.plugin.fxcop;
+import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
+import npanday.PlatformUnsupportedException;
+import npanday.artifact.AssemblyResolver;
import npanday.artifact.NPandayArtifactResolutionException;
+import npanday.executable.ExecutableRequirement;
+import npanday.executable.ExecutionException;
+import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import npanday.executable.ExecutionException;
-import npanday.PlatformUnsupportedException;
-import npanday.ArtifactType;
-import npanday.artifact.AssemblyResolver;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.Artifact;
import org.codehaus.plexus.util.FileUtils;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Set;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
/**
* Runs the FxCop Code Analysis Tool for the specified project's assembly.
@@ -151,8 +152,7 @@ public class FxCopMojo
try
{
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, profile, getCommands(),
- null ).execute();
+ netExecutableFactory.getNetExecutableFor( new ExecutableRequirement( vendor, null, frameworkVersion, profile ), getCommands(), null ).execute();
}
catch ( ExecutionException e )
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java Mon Dec 12 12:16:06 2011
@@ -18,38 +18,34 @@
*/
package npanday.plugin.ilmerge;
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import npanday.ArtifactType;
-import npanday.ArtifactTypeHelper;
import npanday.PlatformUnsupportedException;
+import npanday.executable.ExecutableRequirement;
import npanday.executable.ExecutionException;
-import npanday.executable.compiler.KeyInfo;
-import npanday.executable.compiler.CompilerCapability;
import npanday.executable.compiler.CompilerConfig;
import npanday.executable.compiler.CompilerExecutable;
import npanday.executable.compiler.CompilerRequirement;
+import npanday.executable.compiler.KeyInfo;
import npanday.vendor.Vendor;
-import npanday.vendor.VendorFactory;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
-import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* Merges assemblies into unified assembly.
@@ -232,10 +228,9 @@ public class AssemblyMerger extends Abst
// determine how to set /lib:[assemblyPath]
CompilerExecutable compilerExecutable = netExecutableFactory.getCompilerExecutableFor(getCompilerRequirement(),
getCompilerConfig(),
- project,
- profileAssemblyPath);
+ project);
- String assemblyPath = compilerExecutable.getAssemblyPath();
+ File assemblyPath = compilerExecutable.getAssemblyPath();
if ( assemblyPath == null )
{
throw new MojoExecutionException( "NPANDAY-1501-007: Unable to determine assembly path, perhaps missing profileAssemblyPath?" );
@@ -341,7 +336,7 @@ public class AssemblyMerger extends Abst
}
List commands = new ArrayList();
- commands.add("/lib:" + assemblyPath);
+ commands.add("/lib:" + assemblyPath.toString());
for ( String searchDirectoryPath : searchDirectoryPaths )
{
@@ -386,8 +381,7 @@ public class AssemblyMerger extends Abst
}
outputDirectory.mkdirs();
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, executable, commands,
- netHome ).execute();
+ netExecutableFactory.getNetExecutableFor( new ExecutableRequirement( vendor, null, frameworkVersion, executable ), commands, netHome ).execute();
if ( mergedArtifactTempDirectory != null )
{
@@ -461,21 +455,14 @@ public class AssemblyMerger extends Abst
protected CompilerRequirement getCompilerRequirement() throws MojoExecutionException
{
- //Requirement
- CompilerRequirement compilerRequirement = CompilerRequirement.Factory.createDefaultCompilerRequirement();
- compilerRequirement.setLanguage( language );
- compilerRequirement.setFrameworkVersion( frameworkVersion );
- compilerRequirement.setProfile( profile );
- compilerRequirement.setVendorVersion( vendorVersion );
- compilerRequirement.setVendor( vendor );
- return compilerRequirement;
+ return new CompilerRequirement(vendor, vendorVersion, frameworkVersion, profile, language);
}
protected CompilerConfig getCompilerConfig() throws MojoExecutionException
{
//Config
- CompilerConfig compilerConfig = (CompilerConfig) CompilerConfig.Factory.createDefaultExecutableConfig();
+ CompilerConfig compilerConfig = new CompilerConfig();
compilerConfig.setLocalRepository( localRepository );
@@ -504,6 +491,9 @@ public class AssemblyMerger extends Abst
}
compilerConfig.setArtifactType( artifactType );
+ if (profileAssemblyPath != null){
+ compilerConfig.setAssemblyPath( profileAssemblyPath );
+ }
return compilerConfig;
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/InstallerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/InstallerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/InstallerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/InstallerMojo.java Mon Dec 12 12:16:06 2011
@@ -18,30 +18,31 @@
*/
package npanday.plugin.install;
+import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
+import npanday.PlatformUnsupportedException;
+import npanday.artifact.ApplicationConfig;
+import npanday.artifact.ArtifactContext;
+import npanday.dao.Project;
+import npanday.dao.ProjectDao;
import npanday.dao.ProjectDaoException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import npanday.dao.ProjectDependency;
+import npanday.executable.ExecutableRequirement;
+import npanday.executable.ExecutionException;
+import npanday.executable.NetExecutable;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactResolver;
-import npanday.artifact.ArtifactContext;
-import npanday.ArtifactType;
-import npanday.artifact.ApplicationConfig;
-import npanday.executable.NetExecutable;
-import npanday.executable.ExecutionException;
-import npanday.PlatformUnsupportedException;
-import npanday.dao.Project;
-import npanday.dao.ProjectDependency;
-import npanday.dao.ProjectDao;
import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
import java.io.File;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* Installs assembly into the local repository
@@ -152,9 +153,8 @@ public class InstallerMojo
{
try
{
- NetExecutable netExecutable = netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion,
- profile, getCommands(),
- null );
+ NetExecutable netExecutable = netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, null, frameworkVersion, profile ), getCommands(), null );
netExecutable.execute();
getLog().info( "NPANDAY-xxx-003: Installed Assembly into GAC: Assembly = " +
project.getArtifact().getFile() + ", Vendor = " + netExecutable.getVendor().getVendorName() );
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-link-plugin/src/main/java/npanday/plugin/link/LinkerMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-link-plugin/src/main/java/npanday/plugin/link/LinkerMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-link-plugin/src/main/java/npanday/plugin/link/LinkerMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-link-plugin/src/main/java/npanday/plugin/link/LinkerMojo.java Mon Dec 12 12:16:06 2011
@@ -19,15 +19,16 @@
package npanday.plugin.link;
+import npanday.PlatformUnsupportedException;
+import npanday.executable.ExecutableRequirement;
+import npanday.executable.ExecutionException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
-import npanday.executable.ExecutionException;
-import npanday.PlatformUnsupportedException;
import org.apache.maven.project.MavenProject;
import java.io.File;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
/**
* Link modules into assemblies.
@@ -97,8 +98,9 @@ public class LinkerMojo
try
{
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, profile, getCommands(),
- null ).execute();
+ netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, null, frameworkVersion, profile ), getCommands(), null )
+ .execute();
}
catch ( ExecutionException e )
{
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ExistingResxGenerator.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ExistingResxGenerator.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ExistingResxGenerator.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ExistingResxGenerator.java Mon Dec 12 12:16:06 2011
@@ -18,11 +18,8 @@
*/
package npanday.plugin.resgen;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
import npanday.PlatformUnsupportedException;
+import npanday.executable.ExecutableRequirement;
import npanday.executable.ExecutionException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
@@ -31,6 +28,10 @@ import org.apache.maven.project.MavenPro
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Generates existing resx to .resource (binary)
@@ -114,8 +115,9 @@ public class ExistingResxGenerator exten
File file = new File(project.getBuild().getSourceDirectory() + File.separator + embeddedResource.getSourceFile());
if(!file.exists()) continue;
commands = getCommands(file.getAbsoluteFile(), resourceDirectory, embeddedResource.getName());
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, "RESGEN",commands ,
- netHome ).execute();
+ netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, null, frameworkVersion, "RESGEN" ), commands, netHome )
+ .execute();
}
if(embeddedResources == null)
@@ -131,8 +133,10 @@ public class ExistingResxGenerator exten
name = project.getArtifactId() + "." + name.substring(0, name.lastIndexOf('.'));
commands = getCommands(file.getAbsoluteFile(), resourceDirectory, name);
- netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion, "RESGEN",commands ,
- netHome ).execute();
+ netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, null, frameworkVersion, "RESGEN" ), commands,
+ netHome )
+ .execute();
}
}
}
Modified: incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java
URL: http://svn.apache.org/viewvc/incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java?rev=1213206&r1=1213205&r2=1213206&view=diff
==============================================================================
--- incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java (original)
+++ incubator/npanday/branches/1.5.0-azuresupport/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java Mon Dec 12 12:16:06 2011
@@ -23,6 +23,7 @@ import npanday.artifact.ArtifactContext;
import npanday.artifact.NPandayArtifactResolutionException;
import npanday.artifact.NetDependenciesRepository;
import npanday.artifact.NetDependencyMatchPolicy;
+import npanday.executable.ExecutableRequirement;
import npanday.executable.ExecutionException;
import npanday.executable.NetExecutable;
import npanday.model.netdependency.NetDependency;
@@ -106,7 +107,9 @@ public class NetDependencyResolverMojo
*/
private ArtifactContext artifactContext;
- /** @parameter default-value="false" */
+ /**
+ * @parameter default-value="false"
+ */
private boolean skip;
public void execute()
@@ -152,11 +155,11 @@ public class NetDependencyResolverMojo
}
catch ( NPandayArtifactResolutionException e )
{
- throw new MojoExecutionException( e.getMessage(), e );
+ throw new MojoExecutionException( e.getMessage(), e );
}
catch ( IOException e )
{
- throw new MojoExecutionException( e.getMessage(), e );
+ throw new MojoExecutionException( e.getMessage(), e );
}
new File( localRepository, "npanday.artifacts.resolved" ).mkdir();
@@ -175,31 +178,30 @@ public class NetDependencyResolverMojo
List<Dependency> gacInstallDependencies = repository.getDependenciesFor( gacInstallPolicies );
for ( Dependency dependency : gacInstallDependencies )
{
- List<Artifact> artifacts = artifactContext.getArtifactsFor( dependency.getGroupId(),
- dependency.getArtifactId(),
- dependency.getVersion(),
- dependency.getType() );
+ List<Artifact> artifacts =
+ artifactContext.getArtifactsFor( dependency.getGroupId(), dependency.getArtifactId(),
+ dependency.getVersion(), dependency.getType() );
try
{
- NetExecutable netExecutable = netExecutableFactory.getNetExecutableFor( vendor, frameworkVersion,
- "GACUTIL",
- getGacInstallCommandsFor(
- artifacts.get( 0 ) ),
- null );
+ NetExecutable netExecutable = netExecutableFactory.getNetExecutableFor(
+ new ExecutableRequirement( vendor, null, frameworkVersion, "GACUTIL" ),
+ getGacInstallCommandsFor( artifacts.get( 0 ) ), null );
netExecutable.execute();
- getLog().info( "NPANDAY-1600-004: Installed Assembly into GAC: Assembly = " +
- artifacts.get( 0 ).getFile().getAbsolutePath() + ", Vendor = " +
- netExecutable.getVendor().getVendorName() );
+ getLog().info( "NPANDAY-1600-004: Installed Assembly into GAC: Assembly = "
+ + artifacts.get( 0 ).getFile().getAbsolutePath() + ", Vendor = "
+ + netExecutable.getVendor().getVendorName() );
}
catch ( ExecutionException e )
{
- throw new MojoExecutionException( "NPANDAY-1600-005: Unable to execute gacutil: Vendor " + vendor +
- ", frameworkVersion = " + frameworkVersion + ", Profile = " + profile, e );
+ throw new MojoExecutionException(
+ "NPANDAY-1600-005: Unable to execute gacutil: Vendor " + vendor + ", frameworkVersion = "
+ + frameworkVersion + ", Profile = " + profile, e );
}
catch ( PlatformUnsupportedException e )
{
- throw new MojoExecutionException( "NPANDAY-1600-006: Platform Unsupported: Vendor " + vendor +
- ", frameworkVersion = " + frameworkVersion + ", Profile = " + profile, e );
+ throw new MojoExecutionException(
+ "NPANDAY-1600-006: Platform Unsupported: Vendor " + vendor + ", frameworkVersion = "
+ + frameworkVersion + ", Profile = " + profile, e );
}
}
}