incubator-nmaven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sisb...@apache.org
Subject svn commit: r564941 - in /incubator/nmaven/trunk: 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-core/src/main/java/org/apache...
Date Sat, 11 Aug 2007 17:31:25 GMT
Author: sisbell
Date: Sat Aug 11 10:31:23 2007
New Revision: 564941

URL: http://svn.apache.org/viewvc?view=rev&rev=564941
Log:
Deploy functionality with attached artifacts (exe.config).

Modified:
    incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ApplicationConfig.java
    incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
    incubator/nmaven/trunk/components/dotnet-core/src/main/java/org/apache/maven/dotnet/PathUtil.java
    incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/RepositoryConverter.java
    incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImpl.java
    incubator/nmaven/trunk/components/dotnet-repository/src/test/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImplTest.java
    incubator/nmaven/trunk/plugins/maven-deploy-plugin/src/main/java/org/apache/maven/dotnet/plugins/DeployMojo.java
    incubator/nmaven/trunk/plugins/maven-repository-plugin/src/main/java/org/apache/maven/dotnet/plugin/repository/RepositoryConverterForArtifactMojo.java

Modified: incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ApplicationConfig.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ApplicationConfig.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ApplicationConfig.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/ApplicationConfig.java
Sat Aug 11 10:31:23 2007
@@ -16,10 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.maven.dotnet.artifact;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.dotnet.PathUtil;
 
 import java.io.File;
 
@@ -32,18 +32,26 @@
 {
 
     /**
+     * Returns the Maven repository path of the exe.config file.
+     *
+     * @param localRepository the local maven repository
+     * @return the Maven repository path of the exe.config file
+     */
+    File getRepositoryPath( File localRepository );
+
+    /**
      * Returns the source path of the (original) *.exe.config file
      *
      * @return the source path of the (original) *.exe.config file
      */
-    String getConfigSourcePath();
+    File getConfigSourcePath();
 
     /**
      * Returns the target path of the (copied) *.exe.config file
      *
      * @return the target path of the (copied) *.exe.config file
      */
-    String getConfigDestinationPath();
+    File getConfigBuildPath();
 
     /**
      * Factory class for generating default executable configs.
@@ -61,29 +69,41 @@
          * Creates the the application config for the specified artifact. By default, the
config source path for the
          * exe.config is located within the project's src/main/config directory. Neither
parameter value may be null.
          *
-         * @param artifact the executable artifact to which the exe.config file is associated
-         * @param projectBaseDirectory the base directory of the build (which contains the
pom.xml file)
+         * @param artifact              the executable artifact to which the exe.config file
is associated
+         * @param projectBaseDirectory  the base directory of the build (which contains the
pom.xml file)
          * @param projectBuildDirectory the target directory of the build
          * @return the application config for the specified artifact
          */
         public static ApplicationConfig createDefaultApplicationConfig( final Artifact artifact,
                                                                         final File projectBaseDirectory,
-                                                                        final File projectBuildDirectory)
+                                                                        final File projectBuildDirectory
)
         {
             return new ApplicationConfig()
             {
 
-                public String getConfigSourcePath()
+                public File getRepositoryPath( File localRepository )
+                {
+                    File basedir = PathUtil.getMavenLocalRepositoryFileFor( artifact, localRepository
).getParentFile();
+                    StringBuffer buffer = new StringBuffer();
+                    buffer.append( artifact.getArtifactId() ).append( "-" ).append( artifact.getVersion()
);
+                    if ( artifact.getClassifier() != null )
+                    {
+                        buffer.append( "-" ).append( artifact.getClassifier() );
+                    }
+                    buffer.append( ".exe.config" );
+
+                    return new File( basedir, buffer.toString() );
+                }
+
+                public File getConfigSourcePath()
                 {
-                    return new File(
-                        projectBaseDirectory + "/src/main/config/" + artifact.getArtifactId()
+ ".exe.config" )
-                        .getAbsolutePath();
+                    return new File( projectBaseDirectory,
+                                     "/src/main/config/" + artifact.getArtifactId() + ".exe.config"
);
                 }
 
-                public String getConfigDestinationPath()
+                public File getConfigBuildPath()
                 {
-                    return projectBuildDirectory + File.separator + artifact.getArtifactId()
+
-                        ".exe.config";
+                    return new File( projectBuildDirectory, artifact.getArtifactId() + ".exe.config"
);
                 }
             };
         }

Modified: incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-artifact/src/main/java/org/apache/maven/dotnet/artifact/impl/ArtifactInstallerImpl.java
Sat Aug 11 10:31:23 2007
@@ -308,7 +308,7 @@
         throws ArtifactInstallationException
     {
         ApplicationConfig applicationConfig = artifactContext.getApplicationConfigFor( artifact
);
-        File configExeFile = new File( applicationConfig.getConfigDestinationPath() );
+        File configExeFile = applicationConfig.getConfigBuildPath();
         if ( configExeFile.exists() )
         {
             try

Modified: incubator/nmaven/trunk/components/dotnet-core/src/main/java/org/apache/maven/dotnet/PathUtil.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-core/src/main/java/org/apache/maven/dotnet/PathUtil.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-core/src/main/java/org/apache/maven/dotnet/PathUtil.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-core/src/main/java/org/apache/maven/dotnet/PathUtil.java
Sat Aug 11 10:31:23 2007
@@ -19,6 +19,7 @@
 package org.apache.maven.dotnet;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
 
 import java.io.File;
 import java.util.logging.Logger;
@@ -65,6 +66,29 @@
         //String processArchitecture = ( artifact.getType().equals( "gac_generic" ) );
         return new File( gacRepository, "\\" + artifact.getType() + "\\" + artifact.getArtifactId()
+ "\\" + version +
             "__" + artifact.getClassifier() + "\\" + artifact.getArtifactId() + ".dll" );
+    }
+
+    /**
+     * 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 )
+        {
+            logger.warning( "NMAVEN-040-007: Artifact is null - Cannot get repository file."
);
+            return null;
+        }
+        if ( localRepository == null )
+        {
+            logger.warning( "NMAVEN-040-008: Local Repository is null - Cannot get repository
file." );
+            return null;
+        }
+        return new File( localRepository, new DefaultRepositoryLayout().pathOf( artifact
) );
     }
 
     /**

Modified: incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/RepositoryConverter.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/RepositoryConverter.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/RepositoryConverter.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/RepositoryConverter.java
Sat Aug 11 10:31:23 2007
@@ -20,6 +20,7 @@
 
 import org.openrdf.repository.Repository;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.dotnet.artifact.ApplicationConfig;
 
 import java.io.File;
 import java.io.IOException;
@@ -45,6 +46,7 @@
     void convertRepositoryFormat( Repository repository, File mavenRepository )
         throws IOException;
 
-    void convertRepositoryFormatFor( Artifact artifact, Repository repository, File mavenRepository)
+    void convertRepositoryFormatFor( Artifact artifact, ApplicationConfig applicationConfig,
Repository repository,
+                                     File mavenRepository )
         throws IOException;
 }

Modified: incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImpl.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImpl.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImpl.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-repository/src/main/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImpl.java
Sat Aug 11 10:31:23 2007
@@ -24,6 +24,7 @@
 import org.apache.maven.dotnet.dao.ProjectFactory;
 import org.apache.maven.dotnet.registry.DataAccessObjectRegistry;
 import org.apache.maven.dotnet.ArtifactType;
+import org.apache.maven.dotnet.artifact.ApplicationConfig;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
@@ -117,21 +118,24 @@
                     continue;
                 }
             }
+
             if ( !artifact.getType().equals( "exe.config" ) )//This is attached
             {
-                handler = new DefaultArtifactHandler( "pom" );
-                artifact.setArtifactHandler( handler );
+                ArtifactHandler pomhandler = new DefaultArtifactHandler( "pom" );
+                artifact.setArtifactHandler( pomhandler );
 
                 File pomFile = new File( mavenRepository, pathOfPom( artifact ) );
                 FileWriter fileWriter = new FileWriter( pomFile );
                 new MavenXpp3Writer().write( fileWriter, model );
                 IOUtil.close( fileWriter );
             }
+            artifact.setArtifactHandler( handler );
         }
         dao.closeConnection();
     }
 
-    public void convertRepositoryFormatFor( Artifact artifact, Repository repository, File
mavenRepository )
+    public void convertRepositoryFormatFor( Artifact artifact, ApplicationConfig applicationConfig,
+                                            Repository repository, File mavenRepository )
         throws IOException
     {
         ProjectDao dao = (ProjectDao) daoRegistry.find( "dao:project" );
@@ -163,6 +167,15 @@
             }
         }
 
+        if ( applicationConfig != null )
+        {
+            File destPath = applicationConfig.getConfigBuildPath();
+            if ( destPath.exists() )
+            {
+                FileUtils.copyFile( destPath, applicationConfig.getRepositoryPath( mavenRepository
) );
+            }
+        }
+
         if ( !artifact.getType().equals( "exe.config" ) )//This is attached
         {
             ArtifactHandler pomhandler = new DefaultArtifactHandler( "pom" );
@@ -173,7 +186,7 @@
             new MavenXpp3Writer().write( fileWriter, model );
             IOUtil.close( fileWriter );
         }
-        
+
         artifact.setArtifactHandler( handler );
 
         dao.closeConnection();

Modified: incubator/nmaven/trunk/components/dotnet-repository/src/test/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImplTest.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/components/dotnet-repository/src/test/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImplTest.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/components/dotnet-repository/src/test/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImplTest.java
(original)
+++ incubator/nmaven/trunk/components/dotnet-repository/src/test/java/org/apache/maven/dotnet/repository/impl/RepositoryConverterImplTest.java
Sat Aug 11 10:31:23 2007
@@ -74,7 +74,7 @@
         artifact.setFile( artifactFile );
         try
         {
-            repositoryConverter.convertRepositoryFormatFor( artifact, repository, testRepo
);
+            repositoryConverter.convertRepositoryFormatFor( artifact, null, repository, testRepo
);
         }
         catch ( IOException e )
         {

Modified: incubator/nmaven/trunk/plugins/maven-deploy-plugin/src/main/java/org/apache/maven/dotnet/plugins/DeployMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-deploy-plugin/src/main/java/org/apache/maven/dotnet/plugins/DeployMojo.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-deploy-plugin/src/main/java/org/apache/maven/dotnet/plugins/DeployMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-deploy-plugin/src/main/java/org/apache/maven/dotnet/plugins/DeployMojo.java
Sat Aug 11 10:31:23 2007
@@ -3,16 +3,18 @@
 import org.apache.maven.artifact.deployer.ArtifactDeployer;
 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.apache.maven.dotnet.artifact.ArtifactContext;
+import org.apache.maven.dotnet.artifact.ApplicationConfig;
 
 import java.io.File;
+import java.util.Set;
+import java.util.HashSet;
 
 /**
  * Deploy's dlls
@@ -55,21 +57,43 @@
     /**
      * @component
      */
-    private ArtifactContext artifactContext;
+    private ArtifactFactory artifactFactory;
 
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        Artifact artifact = project.getArtifact();
+        Artifact projectArtifact = project.getArtifact();
+        deployArtifacts.add( projectArtifact );
 
         if ( ! "pom".equals( packaging ) )
         {
-            artifact.addMetadata( new ProjectArtifactMetadata( artifact, project.getFile()
) );
+            projectArtifact.addMetadata( new ProjectArtifactMetadata( projectArtifact, project.getFile()
) );
         }
-        
+
+        ApplicationConfig config = ApplicationConfig.Factory.createDefaultApplicationConfig(
project.getArtifact(),
+                                                                                        
    project.getBasedir(),
+                                                                                        
    new File(
+                                                                                        
        project.getBuild().getDirectory() ) );
+        File exePath = config.getRepositoryPath( new File( localRepo.getBasedir() ) );
+        if ( exePath.exists() )
+        {
+            Artifact attachedArtifact = artifactFactory.createArtifact( projectArtifact.getGroupId(),
+                                                                        projectArtifact.getArtifactId(),
+                                                                        project.getVersion(),
packaging, "exe.config" );
+            try
+            {
+                artifactDeployer.deploy( exePath, attachedArtifact,
+                                         project.getDistributionManagementArtifactRepository(),
localRepo );
+            }
+            catch ( ArtifactDeploymentException e )
+            {
+                throw new MojoExecutionException( "NMAVEN-DEPLOY: Deploy Failed", e );
+            }
+        }
+
         try
         {
-            artifactDeployer.deploy( project.getArtifact().getFile(), artifact,
+            artifactDeployer.deploy( project.getArtifact().getFile(), projectArtifact,
                                      project.getDistributionManagementArtifactRepository(),
localRepo );
         }
         catch ( ArtifactDeploymentException e )

Modified: incubator/nmaven/trunk/plugins/maven-repository-plugin/src/main/java/org/apache/maven/dotnet/plugin/repository/RepositoryConverterForArtifactMojo.java
URL: http://svn.apache.org/viewvc/incubator/nmaven/trunk/plugins/maven-repository-plugin/src/main/java/org/apache/maven/dotnet/plugin/repository/RepositoryConverterForArtifactMojo.java?view=diff&rev=564941&r1=564940&r2=564941
==============================================================================
--- incubator/nmaven/trunk/plugins/maven-repository-plugin/src/main/java/org/apache/maven/dotnet/plugin/repository/RepositoryConverterForArtifactMojo.java
(original)
+++ incubator/nmaven/trunk/plugins/maven-repository-plugin/src/main/java/org/apache/maven/dotnet/plugin/repository/RepositoryConverterForArtifactMojo.java
Sat Aug 11 10:31:23 2007
@@ -23,7 +23,7 @@
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.dotnet.repository.RepositoryConverter;
-import org.apache.maven.dotnet.artifact.ArtifactContext;
+import org.apache.maven.dotnet.artifact.ApplicationConfig;
 import org.openrdf.repository.sail.SailRepository;
 import org.openrdf.repository.RepositoryException;
 import org.openrdf.sail.memory.MemoryStore;
@@ -56,6 +56,7 @@
      */
     private RepositoryConverter repositoryConverter;
 
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -70,9 +71,14 @@
             throw new MojoExecutionException( e.getMessage() );
         }
 
+        ApplicationConfig config = ApplicationConfig.Factory.createDefaultApplicationConfig(
project.getArtifact(),
+                                                                                        
    project.getBasedir(),
+                                                                                        
    new File(
+                                                                                        
        project.getBuild().getDirectory() ) );
         try
         {
-            repositoryConverter.convertRepositoryFormatFor( project.getArtifact(), rdfRepository,
localRepository );
+            repositoryConverter.convertRepositoryFormatFor( project.getArtifact(), config,
rdfRepository,
+                                                            localRepository );
         }
         catch ( IOException e )
         {



Mime
View raw message