continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r385975 - in /maven/continuum/branches/continuum-1.0.x: continuum-api/src/main/java/org/apache/maven/continuum/configuration/ continuum-api/src/main/java/org/apache/maven/continuum/execution/ continuum-core/src/main/java/org/apache/maven/co...
Date Wed, 15 Mar 2006 06:00:33 GMT
Author: brett
Date: Tue Mar 14 22:00:30 2006
New Revision: 385975

URL: http://svn.apache.org/viewcvs?rev=385975&view=rev
Log:
[CONTINUUM-609] add a deployment repository to be used at the end of a Maven 2 build to deploy
artifacts, if configured. Note that the MDO is changed, but its safe - JPOX updates the database
with a nulled field as desired.

Added:
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
  (with props)
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
  (with props)
Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/action/InitializationChecker.java
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/WEB-INF/web.xml
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/Configure.vm
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/ConfigureContinuum.vm
    maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/EditContinuumConfiguration.vm

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
Tue Mar 14 22:00:30 2006
@@ -49,6 +49,10 @@
 
     void setWorkingDirectory( File workingDirectory );
 
+    File getDeploymentRepositoryDirectory();
+
+    void setDeploymentRepositoryDirectory( File deploymentRepositoryDirectory );
+
     void setJdks( Map jdks );
 
     String getCompanyLogo();

Modified: maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
Tue Mar 14 22:00:30 2006
@@ -20,6 +20,7 @@
 import org.apache.maven.continuum.model.project.Project;
 
 import java.io.File;
+import java.util.List;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -38,4 +39,7 @@
     boolean isBuilding( Project project );
 
     void killProcess( Project project );
+
+    List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition )
+        throws ContinuumBuildExecutorException;
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Tue Mar 14 22:00:30 2006
@@ -1469,6 +1469,12 @@
                 throw new ContinuumException( "build output directory can't be null" );
             }
 
+            if ( configuration.get( "conf.deploymentRepositoryDirectory" ) != null )
+            {
+                configurationService.setDeploymentRepositoryDirectory(
+                    configurationService.getFile( (String) configuration.get( "conf.deploymentRepositoryDirectory"
) ) );
+            }
+
             if ( configuration.get( "conf.url" ) != null )
             {
                 configurationService.setUrl( (String) configuration.get( "conf.url" ) );

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Tue Mar 14 22:00:30 2006
@@ -253,6 +253,8 @@
 
                 actionManager.lookup( "execute-builder" ).execute( actionContext );
 
+                actionManager.lookup( "deploy-artifact" ).execute( actionContext );
+
                 String s = (String) actionContext.get( AbstractContinuumAction.KEY_BUILD_ID
);
 
                 if ( s != null )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
Tue Mar 14 22:00:30 2006
@@ -114,6 +114,17 @@
         systemConf.setWorkingDirectory( workingDirectory.getAbsolutePath() );
     }
 
+    public File getDeploymentRepositoryDirectory()
+    {
+        return getFile( systemConf.getDeploymentRepositoryDirectory() );
+    }
+
+    public void setDeploymentRepositoryDirectory( File deploymentRepositoryDirectory )
+    {
+        systemConf.setDeploymentRepositoryDirectory(
+            deploymentRepositoryDirectory != null ? deploymentRepositoryDirectory.getAbsolutePath()
: null );
+    }
+
     public void setJdks( Map jdks )
     {
         this.jdks = jdks;
@@ -207,11 +218,16 @@
 
     public File getFile( String filename )
     {
-        File f = new File( filename );
+        File f = null;
 
-        if ( !f.isAbsolute() )
+        if ( filename != null && filename.length() != 0 )
         {
-            f = new File( applicationHome, filename );
+            f = new File( filename );
+
+            if ( !f.isAbsolute() )
+            {
+                f = new File( applicationHome, filename );
+            }
         }
 
         return f;

Added: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java?rev=385975&view=auto
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
(added)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
Tue Mar 14 22:00:30 2006
@@ -0,0 +1,131 @@
+package org.apache.maven.continuum.core.action;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
+import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
+import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.store.ContinuumStore;
+import org.apache.maven.continuum.utils.WorkingDirectoryService;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class DeployArtifactContinuumAction
+    extends AbstractContinuumAction
+{
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+
+    /**
+     * @plexus.requirement
+     */
+    private BuildExecutorManager buildExecutorManager;
+
+    /**
+     * @plexus.requirement
+     */
+    private ContinuumStore store;
+
+    /**
+     * @plexus.requirement
+     */
+    private WorkingDirectoryService workingDirectoryService;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactDeployer artifactDeployer;
+
+    /**
+     * @plexus.requirement
+     */
+    private MavenBuilderHelper builderHelper;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    public void execute( Map context )
+        throws Exception
+    {
+        // ----------------------------------------------------------------------
+        // Get parameters from the context
+        // ----------------------------------------------------------------------
+
+        File deploymentRepositoryDirectory = configurationService.getDeploymentRepositoryDirectory();
+
+        if ( deploymentRepositoryDirectory != null )
+        {
+            Project project = store.getProjectWithBuildDetails( getProjectId( context ) );
+
+            ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor(
project.getExecutorId() );
+
+            // ----------------------------------------------------------------------
+            // This is really a precondition for this action to execute
+            // ----------------------------------------------------------------------
+
+            if ( project.getState() == ContinuumProjectState.OK )
+            {
+                BuildDefinition buildDefinition = store.getBuildDefinition( getBuildDefinitionId(
context ) );
+
+                List artifacts = buildExecutor.getDeployableArtifacts(
+                    workingDirectoryService.getWorkingDirectory( project ), buildDefinition
);
+
+                for ( Iterator i = artifacts.iterator(); i.hasNext(); )
+                {
+                    Artifact artifact = (Artifact) i.next();
+
+                    ArtifactRepository localRepository = builderHelper.getLocalRepository();
+
+                    ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();
+
+                    if ( !deploymentRepositoryDirectory.exists() )
+                    {
+                        deploymentRepositoryDirectory.mkdirs();
+                    }
+
+                    String location = deploymentRepositoryDirectory.toURL().toExternalForm();
+                    ArtifactRepository deploymentRepository =
+                        artifactRepositoryFactory.createDeploymentArtifactRepository( "deployment-repository",
location,
+                                                                                      repositoryLayout,
true );
+
+                    artifactDeployer.deploy( artifact.getFile(), artifact, deploymentRepository,
localRepository );
+                }
+            }
+        }
+    }
+}

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/core/action/DeployArtifactContinuumAction.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Tue Mar 14 22:00:30 2006
@@ -17,6 +17,7 @@
  */
 
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.utils.WorkingDirectoryService;
 import org.apache.maven.continuum.utils.shell.ExecutionResult;
 import org.apache.maven.continuum.utils.shell.ShellCommandHelper;
@@ -29,6 +30,7 @@
 import java.io.File;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Collections;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -209,6 +211,13 @@
     public void killProcess( Project project )
     {
         shellCommandHelper.killProcess( project.getId() );
+    }
+
+    public List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition
)
+        throws ContinuumBuildExecutorException
+    {
+        // Not supported by this builder
+        return Collections.EMPTY_LIST;
     }
 
     public File getWorkingDirectory( Project project )

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Tue Mar 14 22:00:30 2006
@@ -295,7 +295,7 @@
 
             ProfileManager profileManager = new DefaultProfileManager( container, settings
);
 
-            project = projectBuilder.build( file, getRepository( settings ), profileManager,
false );
+            project = projectBuilder.build( file, getLocalRepository(), profileManager, false
);
 
             if ( getLogger().isDebugEnabled() )
             {
@@ -353,6 +353,11 @@
         }
 
         return project;
+    }
+
+    public ArtifactRepository getLocalRepository()
+    {
+        return getRepository( settings );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenBuilderHelper.java
Tue Mar 14 22:00:30 2006
@@ -18,6 +18,7 @@
 
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 
 import java.io.File;
 
@@ -37,4 +38,6 @@
 
     void mapMavenProjectToContinuumProject( MavenProject mavenProject, Project continuumProject
)
         throws MavenBuilderHelperException;
+
+    ArtifactRepository getLocalRepository();
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
Tue Mar 14 22:00:30 2006
@@ -16,15 +16,19 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.continuum.execution.AbstractBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -80,8 +84,8 @@
             arguments = "-f " + buildFile + " ";
         }
 
-        arguments += StringUtils.clean( buildDefinition.getArguments() ) + " " +
-            StringUtils.clean( buildDefinition.getGoals() );
+        arguments +=
+            StringUtils.clean( buildDefinition.getArguments() ) + " " + StringUtils.clean(
buildDefinition.getGoals() );
 
         return executeShellCommand( project, executable, arguments, buildOutput );
     }
@@ -89,6 +93,25 @@
     public void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition
buildDefinition )
         throws ContinuumBuildExecutorException
     {
+        File f = getPomFile( buildDefinition, workingDirectory );
+
+        if ( !f.exists() )
+        {
+            throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor."
);
+        }
+
+        try
+        {
+            builderHelper.mapMetadataToProject( f, project );
+        }
+        catch ( MavenBuilderHelperException e )
+        {
+            throw new ContinuumBuildExecutorException( "Error while mapping metadata.", e
);
+        }
+    }
+
+    private static File getPomFile( BuildDefinition buildDefinition, File workingDirectory
)
+    {
         File f = null;
 
         if ( buildDefinition != null )
@@ -106,18 +129,44 @@
             f = new File( workingDirectory, "pom.xml" );
         }
 
+        return f;
+    }
+
+    public List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition
)
+        throws ContinuumBuildExecutorException
+    {
+        File f = getPomFile( buildDefinition, workingDirectory );
+
         if ( !f.exists() )
         {
-            throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor."
);
+            throw new ContinuumBuildExecutorException( "Could not find Maven project descriptor
'" + f + "'." );
         }
 
+        MavenProject project;
         try
         {
-            builderHelper.mapMetadataToProject( f, project );
+            project = builderHelper.getMavenProject( f );
         }
         catch ( MavenBuilderHelperException e )
         {
-            throw new ContinuumBuildExecutorException( "Error while mapping metadata.", e
);
+            throw new ContinuumBuildExecutorException(
+                "Unable to read the Maven project descriptor '" + f + "': " + e.getMessage(),
e );
+        }
+
+        List artifacts = new ArrayList( 1 );
+
+        // Maven could help us out a lot more here by knowing how to get the deployment artifacts
from a project.
+        // TODO: this is currently quite lame
+        if ( !"pom".equals( project.getPackaging() ) )
+        {
+            Artifact artifact = project.getArtifact();
+            String filename = project.getBuild().getFinalName() + "." + artifact.getArtifactHandler().getExtension();
+            artifact.setFile( new File( project.getBuild().getDirectory(), filename ) );
+            if ( artifact.getFile().exists() )
+            {
+                artifacts.add( artifact );
+            }
         }
+        return artifacts;
     }
 }

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/resources/META-INF/plexus/components.xml
Tue Mar 14 22:00:30 2006
@@ -657,6 +657,34 @@
     </component>
     <component>
       <role>org.codehaus.plexus.action.Action</role>
+      <role-hint>deploy-artifact</role-hint>
+      <implementation>org.apache.maven.continuum.core.action.DeployArtifactContinuumAction</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.execution.manager.BuildExecutorManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.store.ContinuumStore</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.deployer.ArtifactDeployer</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
+        </requirement>
+      </requirements>
+    </component>
+    <component>
+      <role>org.codehaus.plexus.action.Action</role>
       <role-hint>store-checkout-scm-result</role-hint>
       <implementation>org.apache.maven.continuum.core.action.StoreCheckOutScmResultAction</implementation>
       <requirements>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo (original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-model/src/main/mdo/continuum.mdo Tue
Mar 14 22:00:30 2006
@@ -830,6 +830,11 @@
           <defaultValue>build-output-directory</defaultValue>
         </field>
         <field>
+          <name>deploymentRepositoryDirectory</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
           <name>baseUrl</name>
           <version>1.0.0+</version>
           <type>String</type>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/action/InitializationChecker.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/action/InitializationChecker.java?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/action/InitializationChecker.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/action/InitializationChecker.java
Tue Mar 14 22:00:30 2006
@@ -16,13 +16,13 @@
  * limitations under the License.
  */
 
+import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.system.ContinuumUser;
 import org.apache.maven.continuum.model.system.UserGroup;
-import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.security.ContinuumSecurity;
 import org.apache.maven.continuum.store.ContinuumStore;
-import org.codehaus.plexus.summit.rundata.RunData;
 import org.codehaus.plexus.action.AbstractAction;
+import org.codehaus.plexus.summit.rundata.RunData;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.util.Collections;
@@ -52,7 +52,7 @@
 
         String username = getValue( map, "username" );
 
-        if ( !StringUtils.isEmpty( username) )
+        if ( !StringUtils.isEmpty( username ) )
         {
             adminUser.setUsername( username );
         }
@@ -63,7 +63,7 @@
 
         String password = getValue( map, "password" );
 
-        if ( !StringUtils.isEmpty( password) && password.equals( getValue( map, "password.two"
) ) )
+        if ( !StringUtils.isEmpty( password ) && password.equals( getValue( map,
"password.two" ) ) )
         {
             adminUser.setPassword( getValue( map, "password" ) );
         }
@@ -74,7 +74,7 @@
 
         String fullName = getValue( map, "fullName" );
 
-        if ( !StringUtils.isEmpty( fullName) )
+        if ( !StringUtils.isEmpty( fullName ) )
         {
             adminUser.setFullName( fullName );
         }
@@ -85,7 +85,7 @@
 
         String email = getValue( map, "email" );
 
-        if ( !StringUtils.isEmpty( email) )
+        if ( !StringUtils.isEmpty( email ) )
         {
             adminUser.setEmail( email );
         }
@@ -100,7 +100,7 @@
 
         String workingDirectory = getValue( map, "workingDirectory" );
 
-        if ( !StringUtils.isEmpty( workingDirectory) )
+        if ( !StringUtils.isEmpty( workingDirectory ) )
         {
             configuration.setWorkingDirectory( configuration.getFile( workingDirectory )
);
         }
@@ -111,7 +111,7 @@
 
         String buildOutputDirectory = getValue( map, "buildOutputDirectory" );
 
-        if ( !StringUtils.isEmpty( buildOutputDirectory) )
+        if ( !StringUtils.isEmpty( buildOutputDirectory ) )
         {
             configuration.setBuildOutputDirectory( configuration.getFile( buildOutputDirectory
) );
         }
@@ -120,9 +120,16 @@
             throw new Exception( "You must set a build output directory." );
         }
 
+        String deploymentRepositoryDirectory = getValue( map, "deploymentRepositoryDirectory"
);
+
+        if ( !StringUtils.isEmpty( deploymentRepositoryDirectory ) )
+        {
+            configuration.setDeploymentRepositoryDirectory( configuration.getFile( deploymentRepositoryDirectory
) );
+        }
+
         String baseUrl = getValue( map, "baseUrl" );
 
-        if ( !StringUtils.isEmpty( baseUrl) )
+        if ( !StringUtils.isEmpty( baseUrl ) )
         {
             configuration.setUrl( baseUrl );
         }
@@ -133,21 +140,21 @@
 
         String companyName = getValue( map, "companyName" );
 
-        if ( !StringUtils.isEmpty( companyName) )
+        if ( !StringUtils.isEmpty( companyName ) )
         {
             configuration.setCompanyName( companyName );
         }
 
         String companyLogo = getValue( map, "companyLogo" );
 
-        if ( !StringUtils.isEmpty( companyLogo) )
+        if ( !StringUtils.isEmpty( companyLogo ) )
         {
             configuration.setCompanyLogo( companyLogo );
         }
 
         String companyUrl = getValue( map, "companyUrl" );
 
-        if ( !StringUtils.isEmpty( companyUrl) )
+        if ( !StringUtils.isEmpty( companyUrl ) )
         {
             configuration.setCompanyUrl( companyUrl );
         }

Added: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java?rev=385975&view=auto
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
(added)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
Tue Mar 14 22:00:30 2006
@@ -0,0 +1,195 @@
+package org.apache.maven.continuum.web.servlet;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.utils.PlexusContainerManager;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.util.IOUtil;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class RepositoryBrowseServlet
+    extends HttpServlet
+{
+    private ConfigurationService configuration;
+
+    public void init( ServletConfig servletConfig )
+        throws ServletException
+    {
+        super.init( servletConfig );
+
+        PlexusContainer container = PlexusContainerManager.getInstance().getContainer();
+
+        try
+        {
+            configuration = (ConfigurationService) container.lookup( ConfigurationService.ROLE
);
+        }
+        catch ( ComponentLookupException e )
+        {
+            throw new ServletException( "Unable to get configuration service", e );
+        }
+    }
+
+    protected void doGet( HttpServletRequest req, HttpServletResponse res )
+        throws ServletException, IOException
+    {
+        File f = getFile( req );
+
+        if ( f.exists() )
+        {
+            doDownload( res, f );
+        }
+        else
+        {
+            res.sendError( HttpServletResponse.SC_NOT_FOUND );
+        }
+    }
+
+    private File getFile( HttpServletRequest req )
+    {
+        String path = req.getPathInfo().substring( 1 );
+
+        //Clean url, so url like ../../../../a_file and /path/to_file like /etc/passwd won't
be allow
+        String fileName = cleanUrl( path );
+
+        if ( fileName.indexOf( ".." ) >= 0 || fileName.startsWith( "/" ) )
+        {
+            throw new IllegalArgumentException( "file " + fileName + " isn't allowed." );
+        }
+
+        return new File( configuration.getDeploymentRepositoryDirectory(), fileName );
+    }
+
+    protected long getLastModified( HttpServletRequest req )
+    {
+        File f = getFile( req );
+
+        long mod;
+        if ( f.exists() )
+        {
+            mod = f.lastModified();
+        }
+        else
+        {
+            mod = super.getLastModified( req );
+        }
+        return mod;
+    }
+
+    public String getServletInfo()
+    {
+        return this.getClass().getName() + " by Continuum Team";
+    }
+
+    private void doDownload( HttpServletResponse response, File file )
+        throws IOException
+    {
+        if ( !file.isFile() )
+        {
+            response.sendError( HttpServletResponse.SC_FORBIDDEN );
+        }
+        else
+        {
+            ServletOutputStream output = response.getOutputStream();
+
+            ServletContext context = getServletConfig().getServletContext();
+
+            String mimetype = context.getMimeType( file.getName() );
+
+            if ( mimetype == null )
+            {
+                mimetype = "application/octet-stream";
+            }
+
+            response.setContentType( mimetype );
+
+            if ( !mimetype.startsWith( "text/" ) )
+            {
+                response.setHeader( "Content-Disposition", "attachement; filename=\"" + file.getName()
+ "\"" );
+            }
+
+            IOUtil.copy( new FileInputStream( file ), output );
+        }
+    }
+
+    private String cleanUrl( String url )
+    {
+        if ( url == null )
+        {
+            throw new NullPointerException( "The url cannot be null." );
+        }
+
+        String pathSeparator = "";
+
+        int indexOfDoubleDot = -1;
+
+        // Clean Unix path
+        if ( url.indexOf( "../" ) > 1 )
+        {
+            pathSeparator = "/";
+
+            indexOfDoubleDot = url.indexOf( "../" );
+        }
+
+        // Clean windows path
+        if ( url.indexOf( "..\\" ) > 1 )
+        {
+            pathSeparator = "\\";
+
+            indexOfDoubleDot = url.indexOf( "..\\" );
+        }
+
+        String newUrl = url;
+        if ( indexOfDoubleDot > 1 )
+        {
+            int startOfTextToRemove = url.substring( 0, indexOfDoubleDot - 1 ).lastIndexOf(
pathSeparator );
+
+            String beginUrl = "";
+            if ( startOfTextToRemove >= 0 )
+            {
+                beginUrl = url.substring( 0, startOfTextToRemove );
+            }
+
+            String endUrl = url.substring( indexOfDoubleDot + 3 );
+
+            newUrl = beginUrl + pathSeparator + endUrl;
+
+            // Check if we have other double dot
+            if ( newUrl.indexOf( "../" ) > 1 || newUrl.indexOf( "..\\" ) > 1 )
+            {
+                newUrl = cleanUrl( newUrl );
+            }
+        }
+
+        return newUrl;
+    }
+}

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/java/org/apache/maven/continuum/web/servlet/RepositoryBrowseServlet.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/WEB-INF/web.xml?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/WEB-INF/web.xml
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/WEB-INF/web.xml
Tue Mar 14 22:00:30 2006
@@ -11,6 +11,11 @@
     <load-on-startup>6</load-on-startup>
   </servlet>
   <servlet>
+    <servlet-name>repository</servlet-name>
+    <servlet-class>org.apache.maven.continuum.web.servlet.RepositoryBrowseServlet</servlet-class>
+    <load-on-startup>7</load-on-startup>
+  </servlet>
+  <servlet>
     <servlet-name>continuum</servlet-name>
     <servlet-class>org.codehaus.plexus.summit.Summit</servlet-class>
     <load-on-startup>5</load-on-startup>
@@ -27,6 +32,10 @@
   <servlet-mapping>
     <servlet-name>browse</servlet-name>
     <url-pattern>/continuum/browse</url-pattern>
+  </servlet-mapping>
+  <servlet-mapping>
+    <servlet-name>repository</servlet-name>
+    <url-pattern>/repository/*</url-pattern>
   </servlet-mapping>
   <servlet-mapping>
     <servlet-name>continuum</servlet-name>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/Configure.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/Configure.vm?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/Configure.vm
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/Configure.vm
Tue Mar 14 22:00:30 2006
@@ -45,6 +45,10 @@
           <th>Build Output Directory</th>
           <td><input type="text" name="buildOutputDirectory" value="build-output-directory"
size="100"><br>If you define a relative path, it will be relative to $continuum.configuration.applicationHome</td>
         </tr>
+        <tr>
+          <th>Deployment Repository Directory</th>
+          <td><input type="text" name="deploymentRepositoryDirectory" size="100"><br><strong>Optional.</strong>
If you define a relative path, it will be relative to $continuum.configuration.applicationHome</td>
+        </tr>
         </tbody>
       </table>
       </div>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/ConfigureContinuum.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/ConfigureContinuum.vm?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/ConfigureContinuum.vm
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/ConfigureContinuum.vm
Tue Mar 14 22:00:30 2006
@@ -33,6 +33,16 @@
           <td>$continuum.configuration.buildOutputDirectory</td>
         </tr>
         <tr class="b">
+          <th>Deployment Repository Directory</th>
+          <td>
+          #if ($continuum.configuration.deploymentRepositoryDirectory )
+           $continuum.configuration.deploymentRepositoryDirectory
+          #else
+           -
+          #end
+          </td>
+        </tr>
+        <tr class="b">
           <th>Base URL</th>
           <td>$continuum.configuration.url</td>
         </tr>

Modified: maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/EditContinuumConfiguration.vm
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/EditContinuumConfiguration.vm?rev=385975&r1=385974&r2=385975&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/EditContinuumConfiguration.vm
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-web/src/main/resources/templates/screens/EditContinuumConfiguration.vm
Tue Mar 14 22:00:30 2006
@@ -27,6 +27,14 @@
           <td><input type="text" name="conf.buildOutputDirectory" value="$continuum.configuration.buildOutputDirectory"
size="100"/> If you define a relative path, it will be relative to $continuum.configuration.applicationHome</td>
         </tr>
         <tr class="b">
+          <th>Deployment Repository Directory</th>
+          <td><input type="text" name="conf.deploymentRepositoryDirectory"
+           #if ( $continuum.configuration.deploymentRepositoryDirectory )
+            value="$continuum.configuration.deploymentRepositoryDirectory"
+           #end
+          size="100"/> <strong>Optional</strong>. If you define a relative
path, it will be relative to $continuum.configuration.applicationHome</td>
+        </tr>
+        <tr class="b">
           <th>Base URL</th>
           <td><input type="text" name="conf.url" value="$continuum.configuration.url"
size="100"/></td>
         </tr>



Mime
View raw message