maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r481455 - in /maven/shared/trunk/maven-app-configuration: ./ model/ model/src/ model/src/main/ model/src/main/java/ model/src/main/java/org/ model/src/main/java/org/apache/ model/src/main/java/org/apache/maven/ model/src/main/java/org/apach...
Date Sat, 02 Dec 2006 00:26:22 GMT
Author: brett
Date: Fri Dec  1 16:26:17 2006
New Revision: 481455

URL: http://svn.apache.org/viewvc?view=rev&rev=481455
Log:
add shared app configuration

Added:
    maven/shared/trunk/maven-app-configuration/   (with props)
    maven/shared/trunk/maven-app-configuration/model/   (with props)
    maven/shared/trunk/maven-app-configuration/model/pom.xml   (with props)
    maven/shared/trunk/maven-app-configuration/model/src/
    maven/shared/trunk/maven-app-configuration/model/src/main/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/
      - copied from r481166, maven/continuum/trunk/continuum-configuration/src/main/java/org/apache/maven/continuum/configuration/
    maven/shared/trunk/maven-app-configuration/model/src/main/mdo/
    maven/shared/trunk/maven-app-configuration/model/src/main/mdo/configuration.mdo
      - copied, changed from r481166, maven/continuum/trunk/continuum-configuration/src/main/mdo/configuration.mdo
    maven/shared/trunk/maven-app-configuration/model/src/test/
    maven/shared/trunk/maven-app-configuration/model/src/test/java/
    maven/shared/trunk/maven-app-configuration/pom.xml   (with props)
    maven/shared/trunk/maven-app-configuration/web/   (with props)
    maven/shared/trunk/maven-app-configuration/web/pom.xml   (with props)
    maven/shared/trunk/maven-app-configuration/web/src/
    maven/shared/trunk/maven-app-configuration/web/src/main/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java
  (with props)
    maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java
  (with props)
    maven/shared/trunk/maven-app-configuration/web/src/test/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/
    maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java
  (with props)
    maven/shared/trunk/maven-app-configuration/web/src/test/resources/
Modified:
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeException.java
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeListener.java
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStore.java
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStoreException.java
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/DefaultConfigurationStore.java
    maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/InvalidConfigurationException.java

Propchange: maven/shared/trunk/maven-app-configuration/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Dec  1 16:26:17 2006
@@ -0,0 +1,3 @@
+*.ipr
+*.iws
+*.iml

Propchange: maven/shared/trunk/maven-app-configuration/model/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Dec  1 16:26:17 2006
@@ -0,0 +1,2 @@
+target
+*.iml

Added: maven/shared/trunk/maven-app-configuration/model/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/pom.xml?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/pom.xml (added)
+++ maven/shared/trunk/maven-app-configuration/model/pom.xml Fri Dec  1 16:26:17 2006
@@ -0,0 +1,38 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>maven-app-configuration</artifactId>
+    <groupId>org.apache.maven.shared</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-app-configuration-model</artifactId>
+  <name>Maven Shared Application Configuration Model</name>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.modello</groupId>
+        <artifactId>modello-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>xpp3-writer</goal>
+              <goal>java</goal>
+              <goal>xpp3-reader</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <version>1.1.0</version>
+          <model>src/main/mdo/configuration.mdo</model>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-10</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/shared/trunk/maven-app-configuration/model/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeException.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeException.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeException.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeListener.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeListener.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeListener.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationChangeListener.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStore.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStore.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStore.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStore.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStoreException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStoreException.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStoreException.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/ConfigurationStoreException.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/DefaultConfigurationStore.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/DefaultConfigurationStore.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/DefaultConfigurationStore.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/DefaultConfigurationStore.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,8 +19,8 @@
  * under the License.
  */
 
-import org.apache.maven.continuum.configuration.io.xpp3.ConfigurationXpp3Reader;
-import org.apache.maven.continuum.configuration.io.xpp3.ConfigurationXpp3Writer;
+import org.apache.maven.shared.app.configuration.io.xpp3.ConfigurationXpp3Reader;
+import org.apache.maven.shared.app.configuration.io.xpp3.ConfigurationXpp3Writer;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -143,7 +143,7 @@
     {
         if ( file == null )
         {
-            file = new File( System.getProperty( "user.home" ), "/.m2/continuum.xml" );
+            file = new File( System.getProperty( "user.home" ), "/.m2/shared.xml" );
         }
     }
 }

Modified: maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/InvalidConfigurationException.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/InvalidConfigurationException.java?view=diff&rev=481455&r1=481166&r2=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/InvalidConfigurationException.java
(original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/java/org/apache/maven/shared/app/configuration/InvalidConfigurationException.java
Fri Dec  1 16:26:17 2006
@@ -1,4 +1,4 @@
-package org.apache.maven.continuum.configuration;
+package org.apache.maven.shared.app.configuration;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Copied: maven/shared/trunk/maven-app-configuration/model/src/main/mdo/configuration.mdo (from
r481166, maven/continuum/trunk/continuum-configuration/src/main/mdo/configuration.mdo)
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/model/src/main/mdo/configuration.mdo?view=diff&rev=481455&p1=maven/continuum/trunk/continuum-configuration/src/main/mdo/configuration.mdo&r1=481166&p2=maven/shared/trunk/maven-app-configuration/model/src/main/mdo/configuration.mdo&r2=481455
==============================================================================
--- maven/continuum/trunk/continuum-configuration/src/main/mdo/configuration.mdo (original)
+++ maven/shared/trunk/maven-app-configuration/model/src/main/mdo/configuration.mdo Fri Dec
 1 16:26:17 2006
@@ -21,12 +21,12 @@
   <id>configuration</id>
   <name>Configuration</name>
   <description>
-    Configuration for Continuum.
+    Configuration for Maven applications.
   </description>
   <defaults>
     <default>
       <key>package</key>
-      <value>org.apache.maven.continuum.configuration</value>
+      <value>org.apache.maven.shared.app.configuration</value>
     </default>
   </defaults>
   <classes>

Added: maven/shared/trunk/maven-app-configuration/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/pom.xml?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/pom.xml (added)
+++ maven/shared/trunk/maven-app-configuration/pom.xml Fri Dec  1 16:26:17 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+  <parent>
+    <artifactId>maven-shared-components</artifactId>
+    <groupId>org.apache.maven.shared</groupId>
+    <version>4-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-app-configuration</artifactId>
+  <name>Maven Applications Shared Configuration</name>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <modules>
+    <module>web</module>
+    <module>model</module>
+  </modules>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/shared/trunk/maven-app-configuration/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/shared/trunk/maven-app-configuration/web/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Dec  1 16:26:17 2006
@@ -0,0 +1,2 @@
+target
+*.iml

Added: maven/shared/trunk/maven-app-configuration/web/pom.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/web/pom.xml?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/web/pom.xml (added)
+++ maven/shared/trunk/maven-app-configuration/web/pom.xml Fri Dec  1 16:26:17 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0"?><project>
+  <parent>
+    <artifactId>maven-app-configuration</artifactId>
+    <groupId>org.apache.maven.shared</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-app-configuration-web</artifactId>
+  <name>Maven Shared Application Configuration Web Components</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-app-configuration-model</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/shared/trunk/maven-app-configuration/web/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java
(added)
+++ maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java
Fri Dec  1 16:26:17 2006
@@ -0,0 +1,66 @@
+package org.apache.maven.shared.app.company;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.shared.app.configuration.CompanyPom;
+
+import java.io.IOException;
+
+/**
+ * Holds a company POM to avoid re-reading it.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+public interface CompanyPomHandler
+{
+    String ROLE = CompanyPomHandler.class.getName();
+
+    /**
+     * Retrieve the company model (may be cached).
+     *
+     * @param companyPom the configuration holding the required group and artifact ID
+     * @param localRepository
+     * @return the model
+     * @throws org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException
+     *          if there is a problem locating the existing POM from the repository
+     * @throws org.apache.maven.project.ProjectBuildingException
+     *          if the existing POM in the repository is invalid
+     */
+    Model getCompanyPomModel( CompanyPom companyPom, ArtifactRepository localRepository )
+        throws ProjectBuildingException, ArtifactMetadataRetrievalException;
+
+    /**
+     * Save a company POM in the repository. At present, it does not deploy it to any remote
repositories.
+     * The version in the model will be incremented to the next sequential single digit.
+     *
+     * @param companyModel the company model to save. This is likely to be the same instance
already cached, but will replace the cached version regardless
+     * @param localRepository
+     * @throws java.io.IOException if there is a problem saving the model to the local repository
+     * @throws org.apache.maven.artifact.installer.ArtifactInstallationException
+     *                             if there is a problem saving to the local repository
+     */
+    void save( Model companyModel, ArtifactRepository localRepository )
+        throws IOException, ArtifactInstallationException;
+}

Propchange: maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/CompanyPomHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java
(added)
+++ maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java
Fri Dec  1 16:26:17 2006
@@ -0,0 +1,191 @@
+package org.apache.maven.shared.app.company;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.model.Model;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.shared.app.configuration.CompanyPom;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.util.Collections;
+import java.util.List;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * Holds a company POM from the repository, and is able to find the latest one in a repository.
+ *
+ * @plexus.component
+ */
+public class DefaultCompanyPomHandler
+    implements CompanyPomHandler
+{
+    /**
+     * The company POM.
+     */
+    private Model companyModel;
+
+    /**
+     * @plexus.requirement
+     */
+    private MavenProjectBuilder projectBuilder;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactFactory artifactFactory;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactMetadataSource artifactMetadataSource;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactInstaller installer;
+
+    private static final String ORGANIZATION_LOGO_PROPERTY = "organization.logo";
+
+
+    public Model getCompanyPomModel( CompanyPom companyPom, ArtifactRepository localRepository
)
+        throws ProjectBuildingException, ArtifactMetadataRetrievalException
+    {
+        if ( companyPom != null )
+        {
+            if ( StringUtils.isNotEmpty( companyPom.getGroupId() ) &&
+                StringUtils.isNotEmpty( companyPom.getArtifactId() ) )
+            {
+                if ( companyModel != null )
+                {
+                    if ( !companyPom.getGroupId().equals( companyModel.getGroupId() ) ||
+                        !companyPom.getArtifactId().equals( companyModel.getArtifactId()
) )
+                    {
+                        companyModel = null;
+                    }
+                }
+
+                if ( companyModel == null )
+                {
+                    Artifact artifact = artifactFactory.createProjectArtifact( companyPom.getGroupId(),
+                                                                               companyPom.getArtifactId(),
+                                                                               Artifact.RELEASE_VERSION
);
+
+                    List repositories =
+                        projectBuilder.buildStandaloneSuperProject( localRepository ).getRemoteArtifactRepositories();
+                    List versions =
+                        artifactMetadataSource.retrieveAvailableVersions( artifact, localRepository,
repositories );
+
+                    if ( !versions.isEmpty() )
+                    {
+                        Collections.sort( versions );
+
+                        DefaultArtifactVersion artifactVersion =
+                            (DefaultArtifactVersion) versions.get( versions.size() - 1 );
+                        artifact = artifactFactory.createProjectArtifact( companyPom.getGroupId(),
+                                                                          companyPom.getArtifactId(),
+                                                                          artifactVersion.toString()
);
+
+                        MavenProject project =
+                            projectBuilder.buildFromRepository( artifact, repositories, localRepository
);
+
+                        // We want the original model so that we don't get super POM pollution
+                        companyModel = project.getOriginalModel();
+
+                        // We need to manually propogate the values we want to appear for
editing
+                        if ( companyModel.getOrganization() == null )
+                        {
+                            companyModel.setOrganization( project.getOrganization() );
+                        }
+                        else
+                        {
+                            if ( companyModel.getOrganization().getName() == null )
+                            {
+                                companyModel.getOrganization().setName( project.getOrganization().getName()
);
+                            }
+                            if ( companyModel.getOrganization().getUrl() == null )
+                            {
+                                companyModel.getOrganization().setUrl( project.getOrganization().getUrl()
);
+                            }
+                        }
+                        String logo = project.getProperties().getProperty( ORGANIZATION_LOGO_PROPERTY
);
+                        if ( logo != null )
+                        {
+                            companyModel.getProperties().setProperty( ORGANIZATION_LOGO_PROPERTY,
logo );
+                        }
+                    }
+                }
+            }
+        }
+        return companyModel;
+    }
+
+    public void save( Model companyModel, ArtifactRepository localRepository )
+        throws IOException, ArtifactInstallationException
+    {
+        String v = companyModel.getVersion();
+        String newVersion;
+        if ( v != null )
+        {
+            DefaultArtifactVersion version = new DefaultArtifactVersion( v );
+
+            newVersion = String.valueOf( version.getMajorVersion() + 1 );
+        }
+        else
+        {
+            newVersion = "1";
+        }
+        companyModel.setVersion( newVersion );
+
+        Artifact artifact = artifactFactory.createProjectArtifact( companyModel.getGroupId(),
+                                                                   companyModel.getArtifactId(),
newVersion );
+
+        File f = File.createTempFile( "maven", "pom" );
+        f.deleteOnExit();
+
+        FileWriter fileWriter = new FileWriter( f );
+        try
+        {
+            MavenXpp3Writer writer = new MavenXpp3Writer();
+            writer.write( fileWriter, companyModel );
+        }
+        finally
+        {
+            IOUtil.close( fileWriter );
+        }
+
+        installer.install( f, artifact, localRepository );
+
+        this.companyModel = companyModel;
+    }
+}

Propchange: maven/shared/trunk/maven-app-configuration/web/src/main/java/org/apache/maven/shared/app/company/DefaultCompanyPomHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java?view=auto&rev=481455
==============================================================================
--- maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java
(added)
+++ maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java
Fri Dec  1 16:26:17 2006
@@ -0,0 +1,108 @@
+package org.apache.maven.shared.app.company;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.artifact.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.model.Model;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.shared.app.configuration.CompanyPom;
+import org.codehaus.plexus.PlexusTestCase;
+
+import java.io.IOException;
+
+public class CompanyPomHandlerTest
+    extends PlexusTestCase
+{
+    private CompanyPomHandler companyPomHandler;
+
+    private ArtifactRepository localRepository;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        this.companyPomHandler = (CompanyPomHandler) lookup( CompanyPomHandler.ROLE );
+
+        ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE
);
+
+        localRepository = factory.createDeploymentArtifactRepository( "local", getTestFile(
+            "target/test-repository" ).toURL().toString(), new DefaultRepositoryLayout(),
false );
+    }
+
+    public void testSaveVersionIncrement()
+        throws IOException, ArtifactInstallationException
+    {
+        Model model = new Model();
+        model.setGroupId( "org.apache.maven.test" );
+        model.setArtifactId( "test-artifact" );
+        model.setVersion( "1" );
+
+        companyPomHandler.save( model, localRepository );
+
+        assertEquals( "check model version is incremented", "2", model.getVersion() );
+    }
+
+    public void testSaveVersionNew()
+        throws IOException, ArtifactInstallationException
+    {
+        Model model = new Model();
+        model.setGroupId( "org.apache.maven.test" );
+        model.setArtifactId( "test-artifact" );
+
+        companyPomHandler.save( model, localRepository );
+
+        assertEquals( "check model version is incremented", "1", model.getVersion() );
+    }
+
+    public void testSaveVersionIncrementWithOtherVersionParts()
+        throws IOException, ArtifactInstallationException
+    {
+        Model model = new Model();
+        model.setGroupId( "org.apache.maven.test" );
+        model.setArtifactId( "test-artifact" );
+        model.setVersion( "2.0.1-alpha-2" );
+
+        companyPomHandler.save( model, localRepository );
+
+        assertEquals( "check model version is incremented", "3", model.getVersion() );
+    }
+
+    public void testGetDifferentModel()
+        throws ArtifactMetadataRetrievalException, ProjectBuildingException, ArtifactInstallationException,
IOException
+    {
+        Model model = new Model();
+        model.setGroupId( "org.apache.maven.test" );
+        model.setArtifactId( "test-artifact" );
+        model.setVersion( "2.0.1-alpha-2" );
+
+        companyPomHandler.save( model, localRepository );
+
+        CompanyPom pom = new CompanyPom();
+        pom.setGroupId( "blah" );
+        pom.setArtifactId( "blah" );
+
+        assertNull( companyPomHandler.getCompanyPomModel( pom, localRepository ) );
+    }
+}

Propchange: maven/shared/trunk/maven-app-configuration/web/src/test/java/org/apache/maven/shared/app/company/CompanyPomHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message