From nmaven-commits-return-276-apmail-incubator-nmaven-commits-archive=incubator.apache.org@incubator.apache.org Thu May 10 07:40:45 2007 Return-Path: Delivered-To: apmail-incubator-nmaven-commits-archive@locus.apache.org Received: (qmail 80377 invoked from network); 10 May 2007 07:40:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 May 2007 07:40:44 -0000 Received: (qmail 69739 invoked by uid 500); 10 May 2007 07:40:50 -0000 Delivered-To: apmail-incubator-nmaven-commits-archive@incubator.apache.org Received: (qmail 69710 invoked by uid 500); 10 May 2007 07:40:50 -0000 Mailing-List: contact nmaven-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: nmaven-dev@incubator.apache.org Delivered-To: mailing list nmaven-commits@incubator.apache.org Received: (qmail 69701 invoked by uid 99); 10 May 2007 07:40:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 00:40:50 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 May 2007 00:40:43 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 17ECF1A9838; Thu, 10 May 2007 00:40:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r536766 - in /incubator/nmaven/branches/SI_XPT: components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ components/dotnet-artifact/src/main/r... Date: Thu, 10 May 2007 07:40:22 -0000 To: nmaven-commits@incubator.apache.org From: sisbell@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070510074023.17ECF1A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sisbell Date: Thu May 10 00:40:21 2007 New Revision: 536766 URL: http://svn.apache.org/viewvc?view=rev&rev=536766 Log: Moved out some of the resolving and installing code from the Mojo into the components. I need to reuse it for the visual studio install plugin. Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java?view=diff&rev=536766&r1=536765&r2=536766 ============================================================================== --- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java (original) +++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ArtifactInstaller.java Thu May 10 00:40:21 2007 @@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.ArtifactNotFoundException; +import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.installer.ArtifactInstallationException; import org.apache.maven.project.MavenProject; import org.apache.maven.model.Dependency; @@ -101,12 +102,14 @@ * netplugins. * * @param dependency the dependency to resolve - * @param pomFile * @throws ArtifactInstallationException * @throws ArtifactNotFoundException */ - void resolveAndInstallLibraryDependenciesFor( Dependency dependency, File pomFile ) + void resolveAndInstallLibraryDependenciesFor( Dependency dependency ) throws ArtifactInstallationException , ArtifactNotFoundException; + + void resolveAndInstallNetDependenciesForProfile( String profile, List dependencies ) + throws ArtifactResolutionException, ArtifactNotFoundException, ArtifactInstallationException; /** * Copies .netmodules, that the project is dependenct upon, from the local repo to the project's target directory. Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java?view=diff&rev=536766&r1=536765&r2=536766 ============================================================================== --- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java (original) +++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java Thu May 10 00:40:21 2007 @@ -23,6 +23,11 @@ import org.apache.maven.dotnet.artifact.AssemblyRepositoryLayout; import org.apache.maven.dotnet.artifact.ApplicationConfig; import org.apache.maven.dotnet.artifact.ArtifactType; +import org.apache.maven.dotnet.artifact.NetDependencyMatchPolicy; +import org.apache.maven.dotnet.artifact.NetDependenciesRepository; +import org.apache.maven.dotnet.artifact.AssemblyResolver; +import org.apache.maven.dotnet.registry.RepositoryRegistry; +import org.apache.maven.dotnet.model.netdependency.NetDependency; import org.apache.maven.project.MavenProject; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.VersionRange; @@ -118,6 +123,10 @@ */ private ArtifactFactory artifactFactory; + private AssemblyResolver assemblyResolver; + + private RepositoryRegistry repositoryRegistry; + /** * Constructor. This method is intended to by invoked by the plexus-container, not by the application developer. */ @@ -132,6 +141,33 @@ { this.logger = logger; } + + public void resolveAndInstallNetDependenciesForProfile( String profile, List dependencies ) + throws ArtifactResolutionException, ArtifactNotFoundException, ArtifactInstallationException + { + if ( dependencies == null ) + { + dependencies = new ArrayList(); + } + + NetDependenciesRepository repository = + (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" ); + List matchPolicies = new ArrayList(); + matchPolicies.add( new ProfileMatchPolicy( profile ) ); + dependencies.addAll( repository.getDependenciesFor( matchPolicies ) ); + + assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), dependencies, project.getFile(), + localRepository.getAbsolutePath(), false ); + + //Do Library Installs for Net Dependencies + matchPolicies = new ArrayList(); + matchPolicies.add( new ProfileMatchPolicy( profile ) ); + matchPolicies.add( new ExecutableAndNetPluginMatchPolicy() ); + for ( Dependency dependency : repository.getDependenciesFor( matchPolicies ) ) + { + resolveAndInstallLibraryDependenciesFor( dependency ); + } + } /** * @see org.apache.maven.dotnet.artifact.ArtifactInstaller#installArtifact(org.apache.maven.artifact.Artifact, java.io.File) @@ -336,7 +372,7 @@ } } - public void resolveAndInstallLibraryDependenciesFor( Dependency dependency, File pomFile ) + public void resolveAndInstallLibraryDependenciesFor( Dependency dependency ) throws ArtifactInstallationException, ArtifactNotFoundException { Artifact sourceArtifact = artifactFactory.createBuildArtifact( dependency.getGroupId(), @@ -592,5 +628,43 @@ new MavenXpp3Writer().write( fileWriter, model ); IOUtil.close( fileWriter ); return new ArtifactMetadataImpl( artifact, tempFile ); + } + + private class ExecutableAndNetPluginMatchPolicy + implements NetDependencyMatchPolicy + { + public boolean match( NetDependency netDependency ) + { + return netDependency.getType().equals( ArtifactType.EXE.getPackagingType() ) || + netDependency.getType().equals( ArtifactType.NETPLUGIN.getPackagingType() ); + } + } + + private class ProfileMatchPolicy + implements NetDependencyMatchPolicy + { + + private String profile; + + public ProfileMatchPolicy( String profile ) + { + this.profile = profile; + } + + public boolean match( NetDependency netDependency ) + { + //If no profile is specified in net-dependencies.xml, it matches + if ( netDependency.getProfile() == null || netDependency.getProfile().trim().equals( "" ) ) + { + return true; + } + + if ( profile == null ) + { + return false; + } + + return profile.equals( netDependency.getProfile() ); + } } } Modified: incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml?view=diff&rev=536766&r1=536765&r2=536766 ============================================================================== --- incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml (original) +++ incubator/nmaven/branches/SI_XPT/components/dotnet-artifact/src/main/resources/META-INF/plexus/components.xml Thu May 10 00:40:21 2007 @@ -40,7 +40,13 @@ org.apache.maven.artifact.metadata.ArtifactMetadataSource - + + + org.apache.maven.dotnet.artifact.AssemblyResolver + + + org.apache.maven.dotnet.registry.RepositoryRegistry + Modified: incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java?view=diff&rev=536766&r1=536765&r2=536766 ============================================================================== --- incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java (original) +++ incubator/nmaven/branches/SI_XPT/plugins/maven-resolver-plugin/src/main/java/org/apache/maven/dotnet/plugin/resolver/NetDependencyResolverMojo.java Thu May 10 00:40:21 2007 @@ -153,58 +153,31 @@ dependencies.add( dependency ); } - NetDependenciesRepository repository = - (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" ); - List matchPolicies = new ArrayList(); - matchPolicies.add( new ProfileMatchPolicy( profile ) ); - dependencies.addAll( repository.getDependenciesFor( matchPolicies ) ); - getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + dependencies.size() ); - - if ( localRepository == null ) - { - localRepository = new File( System.getProperty( "user.home" ), ".m2/repository" ).getAbsolutePath(); - } - + artifactContext.init( project, new File( localRepository ) ); try { - assemblyResolver.resolveTransitivelyFor( project, project.getArtifact(), dependencies, pomFile, - localRepository, false ); + artifactContext.getArtifactInstaller().resolveAndInstallNetDependenciesForProfile( profile, + new ArrayList() ); } catch ( ArtifactResolutionException e ) { - throw new MojoExecutionException( "NMAVEN-1600-002: Unable to resolve assemblies", e ); + throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies", e ); } catch ( ArtifactNotFoundException e ) { throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies", e ); } - - //Do Library Installs for Net Dependencies - artifactContext.init( project, new File( localRepository ) ); - matchPolicies = new ArrayList(); - matchPolicies.add( new ProfileMatchPolicy( profile ) ); - matchPolicies.add( new ExecutableAndNetPluginMatchPolicy() ); - for ( Dependency dependency : repository.getDependenciesFor( matchPolicies ) ) + catch ( ArtifactInstallationException e ) { - - try - { - artifactContext.getArtifactInstaller().resolveAndInstallLibraryDependenciesFor( dependency, pomFile ); - - } - catch ( ArtifactNotFoundException e ) - { - throw new MojoExecutionException( "", e ); - } - catch ( ArtifactInstallationException e ) - { - throw new MojoExecutionException( "", e ); - } + throw new MojoExecutionException( "NMAVEN-1600-003: Unable to resolve assemblies", e ); } //Do GAC Install, if needed //TODO: Add in the dependencies from the MOJO config - artifactContext.init( project, new File( localRepository ) ); + NetDependenciesRepository repository = + (NetDependenciesRepository) repositoryRegistry.find( "net-dependencies" ); + getLog().info( "NMAVEN-1600-001: Found net dependencies: Number = " + dependencies.size() ); + List gacInstallPolicies = new ArrayList(); gacInstallPolicies.add( new GacMatchPolicy( true ) ); List gacInstallDependencies = repository.getDependenciesFor( gacInstallPolicies ); @@ -265,44 +238,6 @@ public boolean match( NetDependency netDependency ) { return netDependency.isIsGacInstall() == isGacInstall; - } - } - - private class ExecutableAndNetPluginMatchPolicy - implements NetDependencyMatchPolicy - { - public boolean match( NetDependency netDependency ) - { - return netDependency.getType().equals( ArtifactType.EXE.getPackagingType() ) || - netDependency.getType().equals( ArtifactType.NETPLUGIN.getPackagingType() ); - } - } - - private class ProfileMatchPolicy - implements NetDependencyMatchPolicy - { - - private String profile; - - public ProfileMatchPolicy( String profile ) - { - this.profile = profile; - } - - public boolean match( NetDependency netDependency ) - { - //If no profile is specified in net-dependencies.xml, it matches - if ( netDependency.getProfile() == null || netDependency.getProfile().trim().equals( "" ) ) - { - return true; - } - - if ( profile == null ) - { - return false; - } - - return profile.equals( netDependency.getProfile() ); } } }