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 2012/04/27 11:39:16 UTC
svn commit: r1331360 [1/3] - in /incubator/npanday/trunk: ./ components/
components/dotnet-assembler/
components/dotnet-assembler/src/main/java/npanday/assembler/
components/dotnet-core/ components/dotnet-core/src/main/java/npanday/
components/dotnet-c...
Author: lcorneliussen
Date: Fri Apr 27 11:39:13 2012
New Revision: 1331360
URL: http://svn.apache.org/viewvc?rev=1331360&view=rev
Log:
[NPANDAY-231 Remove RDF repository and model]
o brute-force approach #1; npanday does build, haven't checked its yet
o obsolete modules yet to be deleted
Added:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/LocalRepositoryUtil.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java (contents, props changed)
- copied, changed from r1330657, incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java
incubator/npanday/trunk/plugins/nuget-maven-plugin/
incubator/npanday/trunk/plugins/nuget-maven-plugin/src/
Removed:
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/impl/
incubator/npanday/trunk/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/FileInstallerMojo.java
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependency.java
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NetDependencyResolverMojo.java
Modified:
incubator/npanday/trunk/components/dotnet-assembler/pom.xml
incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java
incubator/npanday/trunk/components/dotnet-core/pom.xml
incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/compiler-plugins.xml
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml
incubator/npanday/trunk/components/dotnet-executable/pom.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/MutableExecutableCapability.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerPluginsRepository.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/NetExecutableFactoryImpl.java
incubator/npanday/trunk/components/dotnet-model/compiler-plugins/compiler-plugins.mdo
incubator/npanday/trunk/components/dotnet-model/compiler-plugins/src/test/resources/sample-compiler-plugins.xml
incubator/npanday/trunk/components/dotnet-msbuild/pom.xml
incubator/npanday/trunk/components/dotnet-msbuild/src/main/java/npanday/msbuild/MsbuildInvoker.java
incubator/npanday/trunk/components/dotnet-nuget/pom.xml
incubator/npanday/trunk/components/dotnet-nuget/src/main/java/npanday/nuget/NugetInvoker.java
incubator/npanday/trunk/components/dotnet-plugin/src/main/java/npanday/plugin/AbstractMojo.java
incubator/npanday/trunk/components/dotnet-registry/src/main/java/npanday/registry/impl/RepositoryRegistryImpl.java
incubator/npanday/trunk/components/pom.xml
incubator/npanday/trunk/dist/npanday-repository-builder/pom.xml
incubator/npanday/trunk/dist/pom.xml
incubator/npanday/trunk/dotnet/assemblies/NPanday.Plugin.MojoGenerator/src/main/resources/pom-java.xml
incubator/npanday/trunk/dotnet/assemblies/NPanday.ProjectImporter/Console/pom.xml
incubator/npanday/trunk/dotnet/pom.xml
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/AbstractCSPackDeployMojo.java
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/CreateCloudServicePackageMojo.java
incubator/npanday/trunk/plugins/azure-maven-plugin/src/main/java/npanday/plugin/azure/ResolveWorkerRoleFilesMojo.java
incubator/npanday/trunk/plugins/library-importer-maven-plugin/src/main/java/npanday/plugin/libraryimporter/resolve/GeneratePackageManifestInfosMojo.java
incubator/npanday/trunk/plugins/maven-aspx-plugin/src/main/java/npanday/plugin/aspx/AspxCompilerMojo.java
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/ComponentInitializerMojo.java
incubator/npanday/trunk/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopAggregateMojo.java
incubator/npanday/trunk/plugins/maven-fxcop-plugin/src/main/java/npanday/plugin/fxcop/FxCopMojo.java
incubator/npanday/trunk/plugins/maven-ilmerge-plugin/src/main/java/npanday/plugin/ilmerge/AssemblyMerger.java
incubator/npanday/trunk/plugins/maven-install-plugin/src/main/java/npanday/plugin/install/InstallerMojo.java
incubator/npanday/trunk/plugins/maven-link-plugin/src/main/java/npanday/plugin/link/LinkerMojo.java
incubator/npanday/trunk/plugins/maven-mojo-generator-plugin/src/main/java/npanday/plugin/generator/MojoGeneratorMojo.java
incubator/npanday/trunk/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ExistingResxGenerator.java
incubator/npanday/trunk/plugins/maven-resgen-plugin/src/main/java/npanday/plugin/resgen/ResourceGeneratorMojo.java
incubator/npanday/trunk/plugins/maven-test-plugin/src/main/java/npanday/plugin/test/TesterMojo.java
incubator/npanday/trunk/plugins/maven-vsinstaller-plugin/src/main/java/npanday/plugin/vsinstaller/VsInstallerMojo.java
incubator/npanday/trunk/plugins/maven-wsdl-plugin/src/main/java/npanday/plugin/wsdl/WsdlGeneratorMojo.java
incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XmlToXsdGeneratorMojo.java
incubator/npanday/trunk/plugins/maven-xsd-plugin/src/main/java/npanday/plugin/xsd/XsdGeneratorMojo.java
incubator/npanday/trunk/plugins/maven-xsp-plugin/src/main/java/npanday/plugin/xsp/XspStarterMojo.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday/plugin/msdeploy/AbstractMsDeployMojo.java
incubator/npanday/trunk/plugins/msdeploy-maven-plugin/src/main/java/npanday/plugin/msdeploy/MsDeployResolveWebRolesMojo.java
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Addin/javabinding/pom.xml
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Devenv/javabinding/pom.xml
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/pom.xml
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Msbuild/javabinding/src/main/java/NPanday/Plugin/Msbuild/MsbuildMojo.java
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.Settings/javabinding/pom.xml
incubator/npanday/trunk/plugins/netplugins/NPanday.Plugin.SysRef/javabinding/pom.xml
incubator/npanday/trunk/plugins/pom.xml
incubator/npanday/trunk/pom.xml
Modified: incubator/npanday/trunk/components/dotnet-assembler/pom.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-assembler/pom.xml?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-assembler/pom.xml (original)
+++ incubator/npanday/trunk/components/dotnet-assembler/pom.xml Fri Apr 27 11:39:13 2012
@@ -40,11 +40,7 @@
<dependency>
<groupId>org.apache.npanday</groupId>
<artifactId>dotnet-model-assembly-plugins</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.npanday</groupId>
- <artifactId>dotnet-artifact</artifactId>
- </dependency>
+ </dependency>
<dependency>
<groupId>org.apache.npanday</groupId>
<artifactId>dotnet-core</artifactId>
Modified: incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java (original)
+++ incubator/npanday/trunk/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java Fri Apr 27 11:39:13 2012
@@ -50,8 +50,7 @@ public interface AssemblerContext
* @return the marshaller for the specified language
* @throws AssemblyInfoException if no marshaller can be found for the specified language
*/
- AssemblyInfoMarshaller getAssemblyInfoMarshallerFor( String language )
- throws AssemblyInfoException;
+ AssemblyInfoMarshaller getAssemblyInfoMarshallerFor( String language ) throws AssemblyInfoException;
/**
* Returns the class extension (cs, vb) for the specified language.
@@ -60,7 +59,7 @@ public interface AssemblerContext
* @return the class extension (cs, vb) for the specified language.
* @throws PlatformUnsupportedException the language is not supported
*/
- String getClassExtensionFor(String language) throws PlatformUnsupportedException;
+ String getClassExtensionFor( String language ) throws PlatformUnsupportedException;
/**
* Initializes the context
@@ -68,7 +67,6 @@ public interface AssemblerContext
* @param mavenProject the maven project
* @throws InitializationException if the context cannot be initialized
*/
- void init( MavenProject mavenProject )
- throws InitializationException;
+ void init( MavenProject mavenProject ) throws InitializationException;
}
Modified: incubator/npanday/trunk/components/dotnet-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/pom.xml?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/pom.xml (original)
+++ incubator/npanday/trunk/components/dotnet-core/pom.xml Fri Apr 27 11:39:13 2012
@@ -72,12 +72,6 @@
</execution>
</executions>
</plugin>
- <!-- enable, if you have @plexus.component in your source
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-maven-plugin</artifactId>
- </plugin>
- -->
</plugins>
<resources>
<resource>
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/LocalRepositoryUtil.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/LocalRepositoryUtil.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/LocalRepositoryUtil.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/LocalRepositoryUtil.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+
+import java.io.File;
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ */
+public class LocalRepositoryUtil
+{
+ public static ArtifactRepository create(String localRepository){
+ return create( new File(localRepository) );
+ }
+
+ public static ArtifactRepository create( File file )
+ {
+ return create( file.toURI() );
+ }
+
+ public static ArtifactRepository create( URI uri )
+ {
+ return new DefaultArtifactRepository( "local", uri.toString(), new DefaultRepositoryLayout() );
+ }
+}
Modified: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java (original)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/PathUtil.java Fri Apr 27 11:39:13 2012
@@ -21,6 +21,7 @@ package npanday;
import com.google.common.base.Preconditions;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
@@ -109,27 +110,6 @@ public final class PathUtil
}
/**
- * Returns the path of the artifact within the local repository using the default repository layout.
- *
- * @param artifact the artifact to find the path of. This value should not be null.
- * @param localRepository the local repository. This value should not be null.
- * @return the path of the artifact within the local maven repository or null if either of the specified
- * parameters is null
- */
- public static File getMavenLocalRepositoryFileFor( Artifact artifact, File localRepository )
- {
- if ( artifact == null )
- {
- throw new NullPointerException( "NPANDAY-040-007: Artifact is null - Cannot get repository file." );
- }
- if ( localRepository == null )
- {
- throw new NullPointerException( "NPANDAY-040-008: Local Repository is null - Cannot get repository file." );
- }
- return new File( localRepository, new DefaultRepositoryLayout().pathOf( artifact ) );
- }
-
- /**
* Returns the path of the artifact within the private application base.
*
*
@@ -146,13 +126,8 @@ public final class PathUtil
logger.warning( "NPANDAY-040-003: Artifact is null - Cannot get application file." );
return null;
}
- if ( localRepository == null )
- {
- logger.warning( "NPANDAY-040-004: Local Repository is null - Cannot get application file." );
- return null;
- }
-
- return getDotNetArtifact( artifact, localRepository, outputDir );
+
+ return getDotNetArtifact( artifact, outputDir );
}
/**
@@ -164,7 +139,7 @@ public final class PathUtil
* @return the path of the artifact within the user assembly cache or null if either of the specified
* parameters is null
*/
- public static File getDotNetArtifact( Artifact artifact, File localRepository, File outputDir )
+ public static File getDotNetArtifact( Artifact artifact, File outputDir )
{
if ( artifact == null )
{
@@ -179,18 +154,7 @@ public final class PathUtil
try
{
- File artifactFile = artifact.getFile();
- File sourceFile;
- if ( artifactFile != null && artifactFile.exists() )
- {
- sourceFile = artifactFile;
- }
- else
- {
- sourceFile = getMavenLocalRepositoryFileFor( artifact, localRepository );
- }
-
- FileUtils.copyFile( sourceFile, targetFile );
+ FileUtils.copyFile( artifact.getFile(), targetFile );
}
catch (IOException ioe)
{
@@ -286,4 +250,34 @@ public final class PathUtil
String folderName = project.getArtifactId();
return new File(new File(project.getBuild().getDirectory(), "packages"), folderName);
}
+
+ /**
+ * Builds an filename with artifact id and extension only.
+ */
+ public static String getPlainArtifactFileName( Artifact artifact )
+ {
+ return artifact.getArtifactId() + "." + ArtifactType.getArtifactTypeForPackagingName(artifact.getType()).getExtension();
+ }
+
+ /**
+ * Will strip the version and classifier!
+ */
+ public static void copyPlainArtifactFileToDirectory( Artifact artifact, File targetFolder)
+ throws IOException
+ {
+ File destination = new File(
+ targetFolder, PathUtil.getPlainArtifactFileName( artifact )
+ );
+
+ try
+ {
+ FileUtils.copyFile(
+ artifact.getFile(), destination
+ );
+ }
+ catch ( IOException e )
+ {
+ throw new IOException( "Error on copying " + artifact + " to" + destination);
+ }
+ }
}
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/ArtifactResolvingContributor.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver;
+
+import org.apache.maven.artifact.Artifact;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ */
+public interface ArtifactResolvingContributor
+{
+ String role = ArtifactResolvingContributor.class.getName();
+
+ /**
+ * Tries to contribute to resolving the artifact. If it is successful, the
+ * artifact should be set to resolved, and a file should be passed to it.
+ *
+ * @param artifact
+ */
+ void contribute(Artifact artifact, Set<Artifact> additionalDependenciesCollector );
+}
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/DefaultNPandayArtifactResolver.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver;
+
+import com.google.common.collect.Sets;
+import npanday.resolver.resolvers.GacResolver;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DebugResolutionListener;
+import org.apache.maven.artifact.resolver.WarningResolutionListener;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Wraps the default Maven artifact resolver and executes all implementations
+ * of {@link npanday.resolver.ArtifactResolvingContributor} for each artiact.
+ *
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ */
+public class DefaultNPandayArtifactResolver
+ extends AbstractLogEnabled
+ implements NPandayArtifactResolver, Contextualizable, Initializable
+{
+ private ArtifactResolvingContributor[] contributors;
+
+ ArtifactResolver original;
+
+ private PlexusContainer container;
+
+ private Set<Artifact> customResolveCache = Sets.newHashSet();
+
+ public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws
+ ArtifactResolutionException,
+ ArtifactNotFoundException
+ {
+ runCustomResolvers( artifact );
+
+ original.resolve(
+ artifact, remoteRepositories, localRepository
+ );
+ }
+
+ public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) throws
+ ArtifactResolutionException,
+ ArtifactNotFoundException
+ {
+ runCustomResolvers( artifact );
+
+ original.resolveAlways(
+ artifact, remoteRepositories, localRepository
+ );
+ }
+
+ public ArtifactResolutionResult resolveTransitively(
+ Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactRepository localRepository,
+ List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) throws
+ ArtifactResolutionException,
+ ArtifactNotFoundException
+ {
+ filter = intercept( filter );
+
+ return original.resolveTransitively(
+ artifacts, originatingArtifact, managedVersions, localRepository, remoteRepositories, source, filter,
+ listeners
+ );
+ }
+
+ private void runCustomResolvers( Artifact artifact )
+ {
+ if ( contributors == null || contributors.length == 0 )
+ {
+ contributors = new ArtifactResolvingContributor[]{ new GacResolver() };
+ }
+
+ for ( ArtifactResolvingContributor contributor : contributors )
+ {
+ if ( !artifact.isResolved() )
+ {
+ Set<Artifact> additionalDependenciesCollector = Sets.newHashSet();
+ contributor.contribute( artifact, additionalDependenciesCollector);
+
+ if (additionalDependenciesCollector.size() > 0){
+ getLogger().error(
+ "NPANDAY-147-006: " + artifact.getId()
+ + " required additional dependencies to be added, but we do not support that yet."
+ );
+ }
+
+ if ( artifact.isResolved() )
+ {
+ customResolveCache.add( artifact );
+
+ getLogger().info(
+ "NPANDAY-147-001: " + contributor.getClass().getName() + " resolved " + artifact.getId()
+ + " to " + artifact.getFile()
+ );
+ }
+ }
+ }
+ }
+
+ private ArtifactFilter intercept( ArtifactFilter filter )
+ {
+ AndArtifactFilter andArtifactFilter = new AndArtifactFilter();
+ if ( filter != null )
+ {
+ andArtifactFilter.add( filter );
+ }
+ andArtifactFilter.add(
+ new ArtifactFilter()
+ {
+ public boolean include( Artifact artifact )
+ {
+ runCustomResolvers( artifact );
+ return true;
+ }
+ }
+ );
+ return andArtifactFilter;
+ }
+
+ public void contextualize( Context context ) throws ContextException
+ {
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ }
+
+ public void initialize() throws InitializationException
+ {
+ try
+ {
+ List list = container.lookupList(
+ ArtifactResolvingContributor.role
+ );
+
+ contributors = (ArtifactResolvingContributor[]) list.toArray( new ArtifactResolvingContributor[0] );
+
+ if (contributors.length == 0) {
+ getLogger().warn( "NPANDAY-147-005: could not find any custom artifact resolving contributors!" );
+ }
+ else{
+ getLogger().debug( "NPANDAY-147-004: resolved " + contributors.length + " contributors: " + list );
+ }
+ }
+ catch ( ComponentLookupException e )
+ {
+ getLogger().error( "NPANDAY-147-003: could not resolve contributors" );
+ }
+ }
+
+ /* Copies of the convenience overloads in DefaultArtifactResolver */
+
+ public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+ Map managedVersions, ArtifactRepository localRepository,
+ List remoteRepositories, ArtifactMetadataSource source )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
+ remoteRepositories, source, null );
+ }
+
+ public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+ Map managedVersions, ArtifactRepository localRepository,
+ List remoteRepositories, ArtifactMetadataSource source,
+ ArtifactFilter filter )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ // TODO: this is simplistic
+ List listeners = new ArrayList();
+ if ( getLogger().isDebugEnabled() )
+ {
+ listeners.add( new DebugResolutionListener( getLogger() ) );
+ }
+
+ listeners.add( new WarningResolutionListener( getLogger() ) );
+
+ return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
+ remoteRepositories, source, filter, listeners );
+
+ }
+
+ public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+ ArtifactRepository localRepository, List remoteRepositories,
+ ArtifactMetadataSource source, ArtifactFilter filter )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
+ remoteRepositories, source, filter );
+
+ }
+
+ public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+ List remoteRepositories, ArtifactRepository localRepository,
+ ArtifactMetadataSource source )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null );
+ }
+
+ public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
+ List remoteRepositories, ArtifactRepository localRepository,
+ ArtifactMetadataSource source, List listeners )
+ throws ArtifactResolutionException, ArtifactNotFoundException
+ {
+ return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
+ remoteRepositories, source, null, listeners );
+ }
+
+ public Set<Artifact> getCustomResolveCache()
+ {
+ return customResolveCache;
+ }
+}
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayArtifactResolver.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver;
+
+import com.google.common.collect.Sets;
+import npanday.resolver.ArtifactResolvingContributor;
+import npanday.resolver.resolvers.GacResolver;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DebugResolutionListener;
+import org.apache.maven.artifact.resolver.WarningResolutionListener;
+import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * NPanday-flavored implementation of the Artifact resolver.
+ */
+public interface NPandayArtifactResolver
+ extends ArtifactResolver
+{
+ /**
+ * All artifacts that have been resolved outside of the maven
+ * core, since they might need special treatment after resolving.
+ *
+ * Create a set intersection with the resulting artifacts you get
+ * from {@link ArtifactResolver#resolveTransitively} in order to do
+ * something with the ones relevant to your context.
+ */
+ public Set<Artifact> getCustomResolveCache();
+}
+
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/NPandayDependencyResolution.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver;
+
+import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
+import npanday.LocalRepositoryUtil;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+
+import java.util.Set;
+
+/**
+ * Resolves project dependencies to a required scope while executing custom
+ * resolver logic for GAC, e.g.
+ *
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ */
+public class NPandayDependencyResolution
+ extends AbstractLogEnabled
+{
+ private NPandayArtifactResolver artifactResolver;
+ private ArtifactFactory artifactFactory;
+ private ArtifactMetadataSource metaDataSource;
+
+ public void require(MavenProject project, ArtifactRepository localRepository, String scope) throws
+ ArtifactResolutionException
+ {
+ try
+ {
+ if ( project.getDependencyArtifacts() == null )
+ {
+ createArtifactsForMaven2BackCompat( project );
+ }
+
+ ArtifactFilter scopeFilter = null;
+ if ( !Strings.isNullOrEmpty( scope )){
+ scopeFilter = new ScopeArtifactFilter( scope );
+ }
+
+ ArtifactResolutionResult result = artifactResolver.resolveTransitively(
+ project.getDependencyArtifacts(), project.getArtifact(), project.getManagedVersionMap(),
+ localRepository, project.getRemoteArtifactRepositories(), metaDataSource,
+ scopeFilter
+ );
+
+ /*
+ * WORKAROUND: transitive dependencies are not cached in MavenProject; in order to let
+ * them "live" for following mojo executions, we'll add the custom resolved
+ * dependencies to the projects DIRECT dependencies
+ * */
+
+ addResolvedSpecialsToProjectDependencies( project, result );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new ArtifactResolutionException( "NPANDAY-148-001: Could not resolve project dependencies", project.getArtifact(), e );
+ }
+ catch ( ArtifactNotFoundException e )
+ {
+ throw new ArtifactResolutionException( "NPANDAY-148-002: Could not resolve project dependencies", project.getArtifact(), e );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ throw new ArtifactResolutionException( "NPANDAY-148-003: Could not resolve project dependencies", project.getArtifact(), e );
+ }
+ }
+
+ private void addResolvedSpecialsToProjectDependencies( MavenProject project, ArtifactResolutionResult result )
+ {
+ Set resolvedArtifacts = result.getArtifacts();
+ Sets.SetView intersection = Sets.intersection(
+ resolvedArtifacts, artifactResolver.getCustomResolveCache()
+ );
+
+ for ( Object ao : intersection )
+ {
+ Artifact a = (Artifact) ao;
+ if ( !project.getDependencyArtifacts().contains( a ) )
+ {
+ getLogger().info( "NPANDAY-184-005: Adding custom resolved " + a + " to project.dependencyArtifacts" );
+
+ project.getDependencyArtifacts().add( a );
+ }
+ else
+ {
+ getLogger().info( "NPANDAY-184-006: " + a + " is yet in project.dependencyArtifacts" );
+ }
+ }
+ }
+
+ private void createArtifactsForMaven2BackCompat( MavenProject project ) throws InvalidVersionSpecificationException
+ {
+ project.setDependencyArtifacts( Sets.newHashSet() );
+ for ( Object o : project.getDependencies() )
+ {
+ Dependency d = (Dependency) o;
+ project.getDependencyArtifacts().add(
+ artifactFactory.createDependencyArtifact(
+ d.getGroupId(), d.getArtifactId(), VersionRange.createFromVersionSpec( d.getVersion() ),
+ d.getType(), d.getClassifier(), d.getScope()
+ )
+ );
+ }
+ }
+}
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/ComReferenceResolver.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,368 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver.resolvers;
+
+import npanday.resolver.ArtifactResolvingContributor;
+import org.apache.maven.artifact.Artifact;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.util.Os;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.DefaultConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ */
+public class ComReferenceResolver
+ extends AbstractLogEnabled
+ implements ArtifactResolvingContributor
+{
+ public void contribute( Artifact artifact, Set<Artifact> additionalDependenciesCollector )
+ {
+ // resolve com reference
+ // flow:
+ // 1. generate the interop dll in temp folder and resolve to that path during dependency resolution
+ // 2. cut and paste the dll to buildDirectory and update the paths once we grab the reference of
+ // MavenProject (CompilerContext.java)
+ if ( artifact.getType().equals( "com_reference" ) )
+ {
+ String tokenId = artifact.getClassifier();
+ String interopPath = null;
+ try
+ {
+ interopPath = generateInteropDll( artifact.getArtifactId(), tokenId );
+ }
+ catch ( IOException e )
+ {
+ getLogger().error(
+ "NPANDAY-150-002: Error creating interop dll for " + artifact.getId()
+ );
+ }
+
+ File f = new File( interopPath );
+
+ if ( !f.exists() )
+ {
+ getLogger().error(
+ "NPANDAY-150-001: Dependency com_reference File not found:" + interopPath + " for " + artifact.getId()
+ );
+ return;
+ }
+
+ artifact.setFile( f );
+ artifact.setResolved( true );
+ }
+ }
+
+ private String generateInteropDll( String name, String classifier )
+ throws IOException
+ {
+
+ File tmpDir;
+ String comReferenceAbsolutePath = "";
+ try
+ {
+ tmpDir = getTempDirectory();
+ }
+ catch ( IOException e )
+ {
+ throw new IOException( "Unable to create temporary directory" );
+ }
+
+ try
+ {
+ comReferenceAbsolutePath = resolveComReferencePath( name, classifier );
+ }
+ catch ( Exception e )
+ {
+ throw new IOException( e.getMessage() );
+ }
+
+ String interopAbsolutePath = tmpDir.getAbsolutePath() + File.separator + "Interop." + name + ".dll";
+ List<String> params = getInteropParameters( interopAbsolutePath, comReferenceAbsolutePath, name );
+
+ try
+ {
+ execute( "tlbimp", params );
+ }
+ catch ( Exception e )
+ {
+ throw new IOException( e.getMessage() );
+ }
+
+ return interopAbsolutePath;
+ }
+
+ private File getTempDirectory()
+ throws IOException
+ {
+ File tempFile = File.createTempFile( "interop-dll-", "" );
+ File tmpDir = new File( tempFile.getParentFile(), tempFile.getName() );
+ tempFile.delete();
+ tmpDir.mkdir();
+ return tmpDir;
+ }
+
+ private List<String> getInteropParameters( String interopAbsolutePath, String comRerefenceAbsolutePath,
+ String namespace )
+ {
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( comRerefenceAbsolutePath );
+ parameters.add( "/out:" + interopAbsolutePath );
+ parameters.add( "/namespace:" + namespace );
+ try
+ {
+ // beginning code for checking of strong name key or signing of projects
+ String key = "";
+ String keyfile = "";
+ String currentWorkingDir = System.getProperty( "user.dir" );
+
+ // Check if Parent pom
+ List<String> modules = readPomAttribute( currentWorkingDir + File.separator + "pom.xml", "module" );
+ if ( !modules.isEmpty() )
+ {
+ // check if there is a matching dependency with the namespace
+ for ( String child : modules )
+ {
+ // check each module pom file if there is existing keyfile
+ String tempDir = currentWorkingDir + File.separator + child;
+ try
+ {
+ List<String> keyfiles = readPomAttribute( tempDir + "\\pom.xml", "keyfile" );
+ if ( keyfiles.get( 0 ) != null )
+ {
+ // PROBLEM WITH MULTIMODULES
+ boolean hasComRef = false;
+ List<String> dependencies = readPomAttribute( tempDir + "\\pom.xml", "groupId" );
+ for ( String item : dependencies )
+ {
+ if ( item.equals( namespace ) )
+ {
+ hasComRef = true;
+ break;
+ }
+ }
+ if ( hasComRef )
+ {
+ key = keyfiles.get( 0 );
+ currentWorkingDir = tempDir;
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ }
+
+ }
+ }
+ else
+ {
+ // not a parent pom, so read project pom file for keyfile value
+
+ List<String> keyfiles = readPomAttribute( currentWorkingDir + File.separator + "pom.xml", "keyfile" );
+ key = keyfiles.get( 0 );
+ }
+ if ( key != "" )
+ {
+ keyfile = currentWorkingDir + File.separator + key;
+ parameters.add( "/keyfile:" + keyfile );
+ }
+ // end code for checking of strong name key or signing of projects
+ }
+ catch ( Exception ex )
+ {
+ }
+
+ return parameters;
+ }
+
+ private List<String> readPomAttribute( String pomFileLoc, String tag )
+ {
+ List<String> attributes = new ArrayList<String>();
+
+ try
+ {
+ File file = new File( pomFileLoc );
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse( file );
+ doc.getDocumentElement().normalize();
+
+ NodeList nodeLst = doc.getElementsByTagName( tag );
+
+ for ( int s = 0; s < nodeLst.getLength(); s++ )
+ {
+ Node currentNode = nodeLst.item( s );
+
+ NodeList childrenList = currentNode.getChildNodes();
+
+ for ( int i = 0; i < childrenList.getLength(); i++ )
+ {
+ Node child = childrenList.item( i );
+ attributes.add( child.getNodeValue() );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+
+ }
+
+ return attributes;
+ }
+
+ private String resolveComReferencePath( String name, String classifier )
+ throws Exception
+ {
+ String[] classTokens = classifier.split( "}" );
+
+ classTokens[1] = classTokens[1].replace( "-", "\\" );
+
+ String newClassifier = classTokens[0] + "}" + classTokens[1];
+
+ String registryPath = "HKEY_CLASSES_ROOT\\TypeLib\\" + newClassifier;
+ registryPath += Os.isArch( "x86" ) ? "\\win32\\" : "\\win64\\";
+ int lineNoOfPath = 1;
+
+ List<String> parameters = new ArrayList<String>();
+ parameters.add( "query" );
+ parameters.add( registryPath );
+ parameters.add( "/ve" );
+
+ StreamConsumer outConsumer = new StreamConsumerImpl();
+ StreamConsumer errorConsumer = new StreamConsumerImpl();
+
+ try
+ {
+ // TODO: investigate why outConsumer ignores newline
+ execute( "reg", parameters, outConsumer, errorConsumer );
+ }
+ catch ( Exception e )
+ {
+ throw new Exception( "Cannot find information of [" + name
+ + "] ActiveX component in your system, you need to install this component first to continue." );
+ }
+
+ // parse outConsumer
+ String out = outConsumer.toString();
+
+ String tokens[] = out.split( "\n" );
+
+ String lineResult = "";
+ String[] result;
+ if ( tokens.length >= lineNoOfPath - 1 )
+ {
+ lineResult = tokens[lineNoOfPath - 1];
+ }
+
+ result = lineResult.split( "REG_SZ" );
+
+ if ( result.length > 1 )
+ {
+ return result[1].trim();
+ }
+
+ return null;
+ }
+
+ // can't use dotnet-executable due to cyclic dependency.
+ private void execute( String executable, List<String> commands )
+ throws Exception
+ {
+ execute( executable, commands, null, null );
+ }
+
+ private void execute( String executable, List<String> commands, StreamConsumer systemOut, StreamConsumer systemError )
+ throws Exception
+ {
+ int result = 0;
+ Commandline commandline = new Commandline();
+ commandline.setExecutable( executable );
+ commandline.addArguments( commands.toArray( new String[commands.size()] ) );
+ try
+ {
+ result = CommandLineUtils.executeCommandLine( commandline, systemOut, systemError );
+
+ System.out.println( "NPANDAY-040-000: Executed command: Commandline = " + commandline + ", Result = "
+ + result );
+
+ if ( result != 0 )
+ {
+ throw new Exception( "NPANDAY-040-001: Could not execute: Command = " + commandline.toString()
+ + ", Result = " + result );
+ }
+ }
+ catch ( CommandLineException e )
+ {
+ throw new Exception( "NPANDAY-040-002: Could not execute: Command = " + commandline.toString(), e);
+ }
+ }
+
+ /**
+ * TODO: refactor this to another class and all methods concerning com_reference StreamConsumer instance that
+ * buffers the entire output
+ */
+ class StreamConsumerImpl
+ implements StreamConsumer
+ {
+
+ private DefaultConsumer consumer;
+
+ private StringBuffer sb = new StringBuffer();
+
+ public StreamConsumerImpl()
+ {
+ consumer = new DefaultConsumer();
+ }
+
+ public void consumeLine( String line )
+ {
+ sb.append( line );
+ if ( getLogger() != null )
+ {
+ consumer.consumeLine( line );
+ }
+ }
+
+ /**
+ * Returns the stream
+ *
+ * @return the stream
+ */
+ public String toString()
+ {
+ return sb.toString();
+ }
+ }
+}
Added: incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java?rev=1331360&view=auto
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java (added)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/java/npanday/resolver/resolvers/GacResolver.java Fri Apr 27 11:39:13 2012
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package npanday.resolver.resolvers;
+
+import npanday.resolver.ArtifactResolvingContributor;
+import npanday.ArtifactTypeHelper;
+import npanday.PathUtil;
+import org.apache.maven.artifact.Artifact;
+
+import java.io.File;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:me@lcorneliussen.de>Lars Corneliussen, Faktum Software</a>
+ *
+ */
+public class GacResolver
+ implements ArtifactResolvingContributor
+{
+ public void contribute(Artifact artifact, Set<Artifact> additionalDependenciesCollector ){
+
+ File artifactFile = null;
+ String artifactType = artifact.getType();
+
+ if ( ArtifactTypeHelper.isDotnetAnyGac( artifactType ))
+ {
+ if (!ArtifactTypeHelper.isDotnet4Gac(artifactType))
+ {
+ artifactFile = PathUtil.getGlobalAssemblyCacheFileFor( artifact, new File( "C:\\WINDOWS\\assembly\\" ) );
+ }
+ else
+ {
+ artifactFile = PathUtil.getGACFile4Artifact(artifact);
+ }
+ }
+
+ if (artifactFile != null && artifactFile.exists()) {
+ artifact.setFile( artifactFile );
+ artifact.setResolved( true );
+ }
+ }
+}
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=1331360&r1=1331359&r2=1331360&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 Fri Apr 27 11:39:13 2012
@@ -1417,7 +1417,6 @@
<pluginClass>npanday.executable.compiler.impl.RubyCompiler</pluginClass>
<vendor>MICROSOFT</vendor>
<executable>RubyCompiler.exe</executable>
- <netDependencyId>RubyCompiler</netDependencyId>
<language>RUBY</language>
<profile>FULL</profile>
<frameworkVersions>
Modified: incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml (original)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/npanday/registry-config.xml Fri Apr 27 11:39:13 2012
@@ -44,24 +44,6 @@
<repository-config>/META-INF/npanday/executable-plugins.xml</repository-config>
</repository>
<repository>
- <repository-name>net-dependencies</repository-name>
- <repository-class>npanday.artifact.impl.NetDependenciesRepositoryImpl</repository-class>
- <repository-config>/META-INF/npanday/net-dependencies.xml</repository-config>
- <init-param>
- <param-name>npanday.version</param-name>
- <param-value>${pom.version}</param-value>
- </init-param>
- </repository>
- <repository>
- <repository-name>connections</repository-name>
- <repository-class>npanday.registry.ConnectionsRepository</repository-class>
- <repository-config>/META-INF/npanday/null.properties</repository-config>
- <init-param>
- <param-name>dao:project</param-name>
- <param-value>npanday.dao.impl.ProjectDaoImpl</param-value>
- </init-param>
- </repository>
- <repository>
<repository-name>configuration-appenders</repository-name>
<repository-class>npanday.plugin.impl.ConfigurationAppendersRepository</repository-class>
<repository-config>/META-INF/npanday/configuration-appenders.xml</repository-config>
Modified: incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ incubator/npanday/trunk/components/dotnet-core/src/main/resources/META-INF/plexus/components.xml Fri Apr 27 11:39:13 2012
@@ -18,6 +18,43 @@
-->
<component-set>
<components>
- <!-- use annotations instead -->
+ <component>
+ <role>npanday.resolver.NPandayArtifactResolver</role>
+ <implementation>npanday.resolver.DefaultNPandayArtifactResolver</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
+ </requirement>
+ </requirements>
+ </component>
+
+ <component>
+ <role>npanday.resolver.NPandayDependencyResolution</role>
+ <implementation>npanday.resolver.NPandayDependencyResolution</implementation>
+ <requirements>
+ <requirement>
+ <role>npanday.resolver.NPandayArtifactResolver</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+ </requirement>
+ </requirements>
+ </component>
+
+ <!-- resolving contributors -->
+ <component>
+ <role>npanday.resolver.ArtifactResolvingContributor</role>
+ <role-hint>gac</role-hint>
+ <implementation>npanday.resolver.resolvers.GacResolver</implementation>
+ </component>
+
+ <component>
+ <role>npanday.resolver.ArtifactResolvingContributor</role>
+ <role-hint>com</role-hint>
+ <implementation>npanday.resolver.resolvers.ComReferenceResolver</implementation>
+ </component>
</components>
</component-set>
Modified: incubator/npanday/trunk/components/dotnet-executable/pom.xml
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/pom.xml?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/pom.xml (original)
+++ incubator/npanday/trunk/components/dotnet-executable/pom.xml Fri Apr 27 11:39:13 2012
@@ -32,11 +32,7 @@
<groupId>org.apache.npanday</groupId>
<artifactId>dotnet-core</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.npanday</groupId>
- <artifactId>dotnet-artifact</artifactId>
- </dependency>
- <dependency>
+ <dependency>
<groupId>org.apache.npanday</groupId>
<artifactId>dotnet-model-executable-plugins</artifactId>
</dependency>
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=1331360&r1=1331359&r2=1331360&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 Fri Apr 27 11:39:13 2012
@@ -42,7 +42,7 @@ public interface ExecutableCapability
* Returns the command options that the executable is capable of supporting.
*
* @return the command capability that the executable is capable of supporting. This capability is used to
- * determine
+ * determine
* the command line parameters that the executable supports.
*/
CommandCapability getCommandCapability();
@@ -117,13 +117,6 @@ public interface ExecutableCapability
java.util.Properties getPluginConfiguration();
/**
- * Returns the net dependency id (within the net-dependencies.xml file).
- *
- * @return the net dependency id
- */
- String getNetDependencyId();
-
- /**
* Retrieves the paths, the executable is most likely to be found on. Can contain
* both existing and not existing paths.
*/
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/MutableExecutableCapability.java Fri Apr 27 11:39:13 2012
@@ -62,8 +62,6 @@ public class MutableExecutableCapability
private String profile;
- private String netDependencyId;
-
private List<String> probingPaths;
public String getProfile()
@@ -176,16 +174,6 @@ public class MutableExecutableCapability
this.commandCapability = commandCapability;
}
- public String getNetDependencyId()
- {
- return netDependencyId;
- }
-
- public void setNetDependencyId( String executableLocation )
- {
- this.netDependencyId = executableLocation;
- }
-
public List<String> getProbingPaths()
{
// if probing paths are defined fot the capability, these are to be
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/NetExecutableFactory.java Fri Apr 27 11:39:13 2012
@@ -25,91 +25,56 @@ import npanday.executable.compiler.Compi
import npanday.executable.compiler.CompilerRequirement;
import npanday.vendor.VendorRequirement;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.project.MavenProject;
import java.io.File;
import java.util.List;
+import java.util.Set;
/**
* Provides services to obtain executables. This interface is intended to be used by <code>AbstractMojo</code>
* implementations to obtain the appropriate executable or compiler.
*
* @author Shane Isbell
+ * @author <a href="me@lcorneliussen.de">Lars Corneliussen, Faktum Software</a>
*/
public interface NetExecutableFactory
{
-
- /**
- * Role used to register component implementations with the container.
- */
String ROLE = NetExecutableFactory.class.getName();
- /**
- * Returns an executable that matches the vendor, framework version and profile. These are typically framework-vendor
- * executables.
- *
- *
- * @param executableRequirement
- * @param commands the user-defined command options to use with the executable
- * @param netHome the install root of the .NET framework
- * @return the executable that matches the vendor, framework version and profile
- * @throws npanday.PlatformUnsupportedException
- * if no executable is found
- */
- NetExecutable getNetExecutableFor( ExecutableRequirement executableRequirement, List<String> commands, File netHome )
- throws PlatformUnsupportedException;
-
- /**
- * Returns an executable that resides within a maven repository. These are typically user-implemented executables.
- *
- *
- * @param groupId the group ID of the executable artifact (as specified within the maven repo)
- * @param artifactId the artifact ID of the executable artifact (as specified within the maven repo)
- * @param vendorRequirement
- * @param localRepository the local maven repository where the executable resides.
- * @param isIsolatedAppDomain the executable can load up assemblies into an isolated application domain. This should
- * be set to true if the application needs to load up assemblies into another app domain
- * and to remotly invoke methods on classes in the other app domain, otherwise it should be
- * set to false.
- * @param targetDir
- * @return the executable that resides within a maven repository.
- * @throws PlatformUnsupportedException if no executable is found
- */
- NetExecutable getNetExecutableFromRepository( String groupId, String artifactId,
- VendorRequirement vendorRequirement, File localRepository,
- List<String> commands, boolean isIsolatedAppDomain, File targetDir )
- throws PlatformUnsupportedException;
-
- /**
- * Returns an executable for compiling .NET applications.
- *
- * @param compilerRequirement the requirements for the compiler
- * @param compilerConfig the configuration for the compiler
- * @param project the maven project
- * @return the executable for compiling .NET applications
- * @throws npanday.PlatformUnsupportedException
- * if no executable is found
- */
- CompilerExecutable getCompilerExecutableFor( CompilerRequirement compilerRequirement, CompilerConfig compilerConfig,
- MavenProject project )
- throws PlatformUnsupportedException;
-
-
- /**
- * Returns a plugin loader for loading and executing a .NET plugin.
- *
- * @param artifact the executable artifact
- * @param vendorRequirement
- * @param localRepository the local maven repository where the executable resides.
- * @param parameterFile the file containing parameter information to inject into the .NET plugin
- * @param mojoName the name of the .NET Mojo implementation
- * @param targetDir
- * @return the plugin loader for executing a .NET plugin
- * @throws PlatformUnsupportedException if no executable is found
- */
- NetExecutable getPluginLoaderFor(
- Artifact artifact, VendorRequirement vendorRequirement, String localRepository, File parameterFile,
- String mojoName, File targetDir ) throws PlatformUnsupportedException;
- Artifact getArtifactFor(String groupId, String artifactId) throws PlatformUnsupportedException;
+ NetExecutable getExecutable(
+ ExecutableRequirement executableRequirement, List<String> commands, File netHome ) throws
+ PlatformUnsupportedException;
+
+ CompilerExecutable getCompilerExecutable(
+ CompilerRequirement compilerRequirement, CompilerConfig compilerConfig, MavenProject project ) throws
+ PlatformUnsupportedException;
+
+ NetExecutable getArtifactExecutable(
+ MavenProject project, Artifact executableArtifact, Set<Artifact> additionalDependencies,
+ VendorRequirement vendorRequirement, ArtifactRepository localRepository, List<String> commands,
+ File targetDir ) throws
+
+ PlatformUnsupportedException, ArtifactResolutionException, ArtifactNotFoundException;
+
+ NetExecutable getPluginExecutable(
+ MavenProject project, Artifact artifact, VendorRequirement vendorRequirement,
+ ArtifactRepository localRepository, File parameterFile, String mojoName, File targetDir ) throws
+ PlatformUnsupportedException,
+ ArtifactResolutionException,
+ ArtifactNotFoundException;
+
+ public NetExecutable getPluginRunner(
+ MavenProject project, Artifact pluginArtifact, Set<Artifact> additionalDependencies,
+ VendorRequirement vendorRequirement, ArtifactRepository localRepository, List<String> commands,
+ File targetDir ) throws
+
+ PlatformUnsupportedException,
+ ArtifactResolutionException,
+ ArtifactNotFoundException;
}
Modified: incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java?rev=1331360&r1=1331359&r2=1331360&view=diff
==============================================================================
--- incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java (original)
+++ incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java Fri Apr 27 11:39:13 2012
@@ -20,12 +20,11 @@ package npanday.executable.impl;
*/
import com.google.common.base.Objects;
+import com.google.common.collect.Lists;
import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
import npanday.PlatformUnsupportedException;
import npanday.RepositoryNotFoundException;
-import npanday.artifact.ArtifactContext;
-import npanday.artifact.ArtifactException;
import npanday.executable.CommandExecutor;
import npanday.executable.ExecutionException;
import npanday.executable.compiler.CompilerCapability;
@@ -84,11 +83,6 @@ public final class CompilerContextImpl
/**
* @plexus.requirement
*/
- private ArtifactContext artifactContext;
-
- /**
- * @plexus.requirement
- */
private RepositoryRegistry repositoryRegistry;
/**
@@ -182,17 +176,8 @@ public final class CompilerContextImpl
public List<Artifact> getDirectModuleDependencies()
{
- List<Artifact> artifacts;
- try
- {
- artifacts = artifactContext.getNetModulesFor( project.getArtifact() );
- }
- catch ( ArtifactException e )
- {
- logger.error( "NPANDAY-061-000: Improper Initialization of the Net Modules", e );
- return new ArrayList<Artifact>();
- //TODO: How to handle this: usually implies improper init of ArtifactContext
- }
+ List<Artifact> artifacts = Lists.newArrayList();
+
if ( config.isTestCompile() && ArtifactTypeHelper.isDotnetModule( config.getArtifactType() ) )
{
artifacts.add( project.getArtifact() );
@@ -378,7 +363,6 @@ public final class CompilerContextImpl
libraries = new ArrayList<Artifact>();
directLibraries = new ArrayList<Artifact>();
modules = new ArrayList<Artifact>();
- artifactContext.init( project, project.getRemoteArtifactRepositories(), config.getLocalRepository() );
compilerCapability = capability;
// initialize base class
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=1331360&r1=1331359&r2=1331360&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 Fri Apr 27 11:39:13 2012
@@ -157,8 +157,6 @@ public final class CompilerPluginsReposi
CommandFilter filter = plugin.getCommandFilter();
platformCapability.setCoreAssemblies( coreAssemblies );
- platformCapability.setNetDependencyId( plugin.getNetDependencyId() );
-
List<String> includes = ( filter != null ) ? filter.getIncludes() : new ArrayList<String>();
List<String> excludes = ( filter != null ) ? filter.getExcludes() : new ArrayList<String>();
platformCapability.setCommandCapability(