Author: sisbell
Date: Tue Jul 24 01:27:14 2007
New Revision: 558960

URL: http://svn.apache.org/viewvc?view=rev&rev=558960
Log:
Fixed application base bug.

Modified:
    
incubator/nmaven/branches/SI_GAC/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java

Modified: 
incubator/nmaven/branches/SI_GAC/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/nmaven/branches/SI_GAC/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java?view=diff&rev=558960&r1=558959&r2=558960
==============================================================================
--- 
incubator/nmaven/branches/SI_GAC/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
 (original)
+++ 
incubator/nmaven/branches/SI_GAC/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
 Tue Jul 24 01:27:14 2007
@@ -181,17 +181,43 @@
         matchPolicies = new ArrayList<NetDependencyMatchPolicy>();
         matchPolicies.add( new ProfileMatchPolicy( profile ) );
         matchPolicies.add( new ExecutableAndNetPluginAndAddinMatchPolicy() );
-        for ( Dependency dependency : repository.getDependenciesFor( 
matchPolicies ) )
+
+        for ( Dependency dependency : dependencies )
         {
-            resolveAndInstallLibraryDependenciesFor( dependency );
+            Artifact sourceArtifact = artifactFactory.createBuildArtifact( 
dependency.getGroupId(),
+                                                                           
dependency.getArtifactId(),
+                                                                           
dependency.getVersion(),
+                                                                           
dependency.getType() );
+            //Resolve the JavaBinding for the .NET plugin
+            ArtifactRepository localArtifactRepo =
+                new DefaultArtifactRepository( "local", "file://" + 
localRepository, new DefaultRepositoryLayout() );
+            if ( sourceArtifact.getType().equals( 
ArtifactType.NETPLUGIN.getPackagingType() ) )
+            {
+                Artifact javaBindingArtifact = 
artifactFactory.createBuildArtifact( sourceArtifact.getGroupId(),
+                                                                               
     sourceArtifact.getArtifactId() +
+                                                                               
         ".JavaBinding",
+                                                                               
     sourceArtifact.getVersion(),
+                                                                               
     "jar" );
+                try
+                {
+                    resolver.resolve( javaBindingArtifact, 
remoteArtifactRepositories, localArtifactRepo);
+                }
+                catch ( ArtifactResolutionException e )
+                {
+                    throw new ArtifactNotFoundException( "", sourceArtifact );
+                }
+            }
         }
+
+        installArtifactAndDependenciesIntoPrivateApplicationBase( new File( 
localRepository.getParentFile(), "pab" ),
+                                                                  null,
+                                                                  
repository.getDependenciesFor( matchPolicies ) );
     }
 
     public void installArtifactAndDependenciesIntoPrivateApplicationBase( File 
applicationBase, Artifact artifact,
                                                                           
List<Dependency> dependencies )
         throws ArtifactInstallationException
     {
-        //File pab = new File( System.getProperty( "user.home" ), ".m2/pab" );
 
         Set<Artifact> artifactDependencies = new HashSet<Artifact>();
         for ( Dependency dependency : dependencies )
@@ -210,7 +236,10 @@
             artifactDependencies.add( artifactDependency );
         }
 
-        artifactDependencies.add( artifact );
+        if ( artifact != null )
+        {
+            artifactDependencies.add( artifact );
+        }
         System.out.println( "Copying into PAB. Count = " + 
artifactDependencies.size() );
         for ( Artifact artifactDependency : artifactDependencies )
         {
@@ -249,31 +278,6 @@
     {
         ApplicationConfig applicationConfig = 
artifactContext.getApplicationConfigFor( artifact );
         File configExeFile = new File( 
applicationConfig.getConfigDestinationPath() );
-        //artifact.getMetadataList().clear();
-        /*
-        if ( modifyProjectMetadata )
-        {
-            try
-            {
-                List<Dependency> dependencies = project.getDependencies();
-                List<Dependency> newDependencies = new ArrayList<Dependency>();
-                for ( Dependency dependency : dependencies )
-                {
-                    if ( !dependency.getType().startsWith( "gac" ) )
-                    {
-                        newDependencies.add( dependency );
-                    }
-                }
-                project.setDependencies( newDependencies );
-                artifact.addMetadata( createArtifactMetadataFor( artifact, 
pomFile, project.getDependencies() ) );
-            }
-            catch ( IOException e )
-            {
-                throw new ArtifactInstallationException( "NMAVEN-002-001: 
Unable to add metadata to artifact", e );
-            }
-            //End GAC HACK
-        }
-*/
 
         try
         {
@@ -365,119 +369,6 @@
         installArtifactWithPom( artifact, tempFile, false );
     }
 
-    //TODO: This is broken
-    private void resolveAndInstallLibraryDependenciesFor( Dependency 
dependency )
-        throws ArtifactInstallationException, ArtifactNotFoundException
-    {
-
-        Artifact sourceArtifact = artifactFactory.createBuildArtifact( 
dependency.getGroupId(),
-                                                                       
dependency.getArtifactId(),
-                                                                       
dependency.getVersion(), dependency.getType() );
-        //Resolve the JavaBinding for the .NET plugin
-        ArtifactRepository localArtifactRepository =
-            new DefaultArtifactRepository( "local", "file://" + 
localRepository, new DefaultRepositoryLayout() );
-        if ( sourceArtifact.getType().equals( 
ArtifactType.NETPLUGIN.getPackagingType() ) )
-        {
-            Artifact javaBindingArtifact = 
artifactFactory.createBuildArtifact( sourceArtifact.getGroupId(),
-                                                                               
 sourceArtifact.getArtifactId() +
-                                                                               
     ".JavaBinding",
-                                                                               
 sourceArtifact.getVersion(), "jar" );
-            try
-            {
-                resolver.resolve( javaBindingArtifact, 
remoteArtifactRepositories, localArtifactRepository );
-            }
-            catch ( ArtifactResolutionException e )
-            {
-                throw new ArtifactNotFoundException( "", sourceArtifact );
-            }
-        }
-
-        //Resolve all the specified dependencies
-        Artifact pomArtifact = artifactFactory.createProjectArtifact( 
dependency.getGroupId(),
-                                                                      
dependency.getArtifactId(),
-                                                                      
dependency.getVersion() );
-        File pomArtifactFile = new File( localRepository, new 
AssemblyRepositoryLayout().pathOf( pomArtifact ) );
-        FileReader fileReader;
-        try
-        {
-            fileReader = new FileReader( pomArtifactFile );
-        }
-        catch ( FileNotFoundException e )
-        {
-            throw new ArtifactNotFoundException( "NMAVEN-000-000: Unable to 
read pom", sourceArtifact );
-        }
-        MavenXpp3Reader reader = new MavenXpp3Reader();
-        Model model;
-        try
-        {
-            model = reader.read( fileReader );
-        }
-        catch ( XmlPullParserException e )
-        {
-            throw new ArtifactNotFoundException( "NMAVEN-000-000: Unable to 
read model", sourceArtifact );
-
-        }
-        catch ( IOException e )
-        {
-            throw new ArtifactNotFoundException( "NMAVEN-000-000: Unable to 
read model", sourceArtifact );
-        }
-        List<Dependency> sourceArtifactDependencies = model.getDependencies();
-        localArtifactRepository =
-            new DefaultArtifactRepository( "local", "file://" + 
localRepository, new AssemblyRepositoryLayout() );
-        Set<Artifact> artifactDependencies = new HashSet<Artifact>();
-        for ( Dependency d : sourceArtifactDependencies )
-        {
-            String scope = ( d.getScope() == null ) ? Artifact.SCOPE_COMPILE : 
d.getScope();
-            Artifact artifact1 = artifactFactory.createDependencyArtifact( 
d.getGroupId(), d.getArtifactId(),
-                                                                           
VersionRange.createFromVersion(
-                                                                               
d.getVersion() ), d.getType(),
-                                                                               
                  d.getClassifier(),
-                                                                               
                  scope, null );
-            artifactDependencies.add( artifact1 );
-
-        }
-
-        ArtifactMetadataImpl meta = new ArtifactMetadataImpl( sourceArtifact, 
null );
-        sourceArtifact.addMetadata( meta );
-        ArtifactResolutionResult result;
-        try
-        {
-            result = resolver.resolveTransitively( artifactDependencies, 
sourceArtifact, localArtifactRepository,
-                                                   remoteArtifactRepositories, 
metadata, new ArtifactFilter()
-            {
-                public boolean include( org.apache.maven.artifact.Artifact 
artifact )
-                {
-                    return !artifact.getType().startsWith( "gac" );
-                }
-            } );
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw new ArtifactNotFoundException( "NMAVEN-000-000: ", 
sourceArtifact );
-        }
-
-        //Do local installing of the dependencies into exe and netplugin repo 
directories
-        AssemblyRepositoryLayout layout = new AssemblyRepositoryLayout();
-        Set<Artifact> artifacts = result.getArtifacts();
-
-        File destDir = new File( localRepository, layout.pathOf( 
sourceArtifact ) ).getParentFile();
-        for ( Artifact artifact : artifacts )
-        {
-            File destFile = new File( destDir, artifact.getFile().getName() );
-            if ( !destFile.exists() || destFile.lastModified() < 
artifact.getFile().lastModified() )
-            {
-                try
-                {
-                    FileUtils.copyFileToDirectory( artifact.getFile(), destDir 
);
-                }
-                catch ( IOException e )
-                {
-                    e.printStackTrace();
-                }
-            }
-        }
-    }
-
     /**
      * @see 
org.apache.maven.dotnet.artifact.ArtifactInstaller#init(org.apache.maven.dotnet.artifact.ArtifactContext,org.apache.maven.project.MavenProject,java.util.List,
 File
      */
@@ -491,55 +382,6 @@
         this.assemblyRepositoryLayout = new AssemblyRepositoryLayout();
         artifactRepository = new DefaultArtifactRepository( "local", "file://" 
+ localRepository.getAbsolutePath(),
                                                             
assemblyRepositoryLayout );
-    }
-
-    /**
-     * Creates the artifact metadata file for the specified artifact.
-     *
-     * @param artifact     the artifact associated with the artifact metadata
-     * @param pomFile      the pom file of the specified artifact
-     * @param dependencies the dependencies of the specified artifact
-     * @return the artifact metadata file for the specified artifact.
-     * @throws IOException if there is a problem reading the pom file
-     */
-    private ArtifactMetadata createArtifactMetadataFor( Artifact artifact, 
File pomFile, List<Dependency> dependencies )
-        throws IOException
-    {
-        FileReader fileReader = new FileReader( pomFile );
-        MavenXpp3Reader reader = new MavenXpp3Reader();
-        Model model;
-        try
-        {
-            model = reader.read( fileReader );
-        }
-        catch ( XmlPullParserException e )
-        {
-            e.printStackTrace();
-            throw new IOException( "NMAVEN-002-013: Unable to read pom file" );
-        }
-        List<Dependency> dest = new ArrayList<Dependency>();
-        dest.addAll( model.getDependencies() );
-        for ( Dependency dependency : dest )
-        {
-            model.removeDependency( dependency );
-        }
-
-        for ( Dependency dependency : dependencies )
-        {
-            //TODO: This condition is only here since transitive gac 
dependencies break the build. This needs to be fixed
-            //within the core.
-            if ( !dependency.getType().startsWith( "gac" ) )
-            {
-                model.addDependency( dependency );
-            }
-        }
-
-        File tempFile = File.createTempFile( "mvninstall", ".pom" );
-        tempFile.deleteOnExit();
-        FileWriter fileWriter = new FileWriter( tempFile );
-        new MavenXpp3Writer().write( fileWriter, model );
-        IOUtil.close( fileWriter );
-        return new ArtifactMetadataImpl( artifact, tempFile );
     }
 
     private class ExecutableAndNetPluginAndAddinMatchPolicy


Reply via email to