aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java25
-rw-r--r--archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java62
-rw-r--r--archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml33
-rw-r--r--archiva-core/pom.xml2
-rw-r--r--archiva-core/src/test/resources/org/apache/maven/archiva/repositories/DefaultActiveManagedRepositoriesTest.xml2
-rw-r--r--archiva-site/src/site/apt/guides/configuration.apt63
-rw-r--r--archiva-site/src/site/apt/guides/security-configuration.apt2
-rw-r--r--archiva-site/src/site/site.xml1
-rw-r--r--archiva-webapp/pom.xml18
-rw-r--r--archiva-webapp/src/appserver-base/conf/archiva.xml1
-rw-r--r--archiva-webapp/src/main/resources/META-INF/plexus/application.xml6
11 files changed, 199 insertions, 16 deletions
diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
index 4a4f7fa50..f3c50fbc0 100644
--- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
+++ b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java
@@ -26,6 +26,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationExce
import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryException;
import org.codehaus.plexus.registry.RegistryListener;
+import org.codehaus.plexus.util.StringUtils;
import java.util.Iterator;
@@ -74,7 +75,11 @@ public class DefaultArchivaConfiguration
public void save( Configuration configuration )
throws RegistryException
{
- Registry section = registry.getSection( KEY );
+ Registry section = registry.getSection( KEY + ".user" );
+ if ( section == null )
+ {
+ section = registry.getSection( KEY + ".base" );
+ }
new ConfigurationRegistryWriter().write( configuration, section );
section.save();
@@ -83,8 +88,16 @@ public class DefaultArchivaConfiguration
public void addChangeListener( RegistryListener listener )
{
- Registry section = registry.getSection( KEY );
- section.addChangeListener( listener );
+ Registry section = registry.getSection( KEY + ".user" );
+ if ( section != null )
+ {
+ section.addChangeListener( listener );
+ }
+ section = registry.getSection( KEY + ".base" );
+ if ( section != null )
+ {
+ section.addChangeListener( listener );
+ }
}
public void initialize()
@@ -105,8 +118,10 @@ public class DefaultArchivaConfiguration
private String removeExpressions( String directory )
{
- String value = org.codehaus.plexus.util.StringUtils.replace( directory, "${appserver.base}", registry.getString( "appserver.base", "${appserver.base}" ) );
- value = org.codehaus.plexus.util.StringUtils.replace( value, "${appserver.home}", registry.getString( "appserver.home", "${appserver.home}" ) );
+ String value = StringUtils.replace( directory, "${appserver.base}",
+ registry.getString( "appserver.base", "${appserver.base}" ) );
+ value = StringUtils.replace( value, "${appserver.home}",
+ registry.getString( "appserver.home", "${appserver.home}" ) );
return value;
}
diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
index 5c17abd6d..4c21b15df 100644
--- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
+++ b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java
@@ -142,6 +142,68 @@ public class ArchivaConfigurationTest
assertEquals( "check value", "index-path", configuration.getIndexPath() );
}
+ public void testStoreConfigurationUser()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ // TODO: remove with commons-configuration 1.4
+ userFile.getParentFile().mkdirs();
+ org.codehaus.plexus.util.FileUtils.fileWrite( userFile.getAbsolutePath(), "<configuration/>" );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = new Configuration();
+ configuration.setIndexPath( "index-path" );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", userFile.exists() );
+ assertFalse( "Check file not created", baseFile.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertEquals( "check value", "index-path", configuration.getIndexPath() );
+ }
+
+ public void testStoreConfigurationFallback()
+ throws Exception
+ {
+ File baseFile = getTestFile( "target/test/test-file.xml" );
+ baseFile.delete();
+ assertFalse( baseFile.exists() );
+
+ File userFile = getTestFile( "target/test/test-file-user.xml" );
+ userFile.delete();
+ assertFalse( userFile.exists() );
+
+ // TODO: remove with commons-configuration 1.4
+ baseFile.getParentFile().mkdirs();
+ org.codehaus.plexus.util.FileUtils.fileWrite( baseFile.getAbsolutePath(), "<configuration/>" );
+
+ ArchivaConfiguration archivaConfiguration =
+ (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" );
+
+ Configuration configuration = new Configuration();
+ configuration.setIndexPath( "index-path" );
+
+ archivaConfiguration.save( configuration );
+
+ assertTrue( "Check file exists", baseFile.exists() );
+ assertFalse( "Check file not created", userFile.exists() );
+
+ // check it
+ configuration = archivaConfiguration.getConfiguration();
+ assertEquals( "check value", "index-path", configuration.getIndexPath() );
+ }
+
public void testRemoveProxiedRepositoryAndStoreConfiguration()
throws Exception
{
diff --git a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml
index 44319293d..00c6fceb1 100644
--- a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml
+++ b/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml
@@ -81,7 +81,32 @@
<configuration>
<properties>
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true"
- config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
+ </properties>
+ </configuration>
+ </component>
+
+ <component>
+ <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
+ <role-hint>test-save-user</role-hint>
+ <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation>
+ <requirements>
+ <requirement>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>save-user</role-hint>
+ </requirement>
+ </requirements>
+ </component>
+ <component>
+ <role>org.codehaus.plexus.registry.Registry</role>
+ <role-hint>save-user</role-hint>
+ <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation>
+ <configuration>
+ <properties>
+ <xml fileName="${basedir}/target/test/test-file-user.xml" config-optional="true" config-forceCreate="true"
+ config-name="org.apache.maven.archiva.user" config-at="org.apache.maven.archiva"/>
+ <xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true"
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
</properties>
</configuration>
</component>
@@ -104,7 +129,7 @@
<configuration>
<properties>
<xml fileName="${basedir}/target/test/test-file.xml" config-optional="true" config-forceCreate="true"
- config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
</properties>
</configuration>
</component>
@@ -127,7 +152,7 @@
<configuration>
<properties>
<xml fileName="${basedir}/target/test/with-proxied-repos.xml"
- config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
</properties>
</configuration>
</component>
@@ -149,7 +174,7 @@
<configuration>
<properties>
<xml fileName="${basedir}/target/test/with-proxied-repos.xml"
- config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
</properties>
</configuration>
</component>
diff --git a/archiva-core/pom.xml b/archiva-core/pom.xml
index ed730ec37..09daa2d48 100644
--- a/archiva-core/pom.xml
+++ b/archiva-core/pom.xml
@@ -71,7 +71,7 @@
<dependency>
<groupId>org.codehaus.plexus.registry</groupId>
<artifactId>plexus-registry-commons</artifactId>
- <version>1.0-alpha-1</version>
+ <version>1.0-alpha-2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<!-- TEST DEPS -->
diff --git a/archiva-core/src/test/resources/org/apache/maven/archiva/repositories/DefaultActiveManagedRepositoriesTest.xml b/archiva-core/src/test/resources/org/apache/maven/archiva/repositories/DefaultActiveManagedRepositoriesTest.xml
index 34d15023a..1fa2e7e1d 100644
--- a/archiva-core/src/test/resources/org/apache/maven/archiva/repositories/DefaultActiveManagedRepositoriesTest.xml
+++ b/archiva-core/src/test/resources/org/apache/maven/archiva/repositories/DefaultActiveManagedRepositoriesTest.xml
@@ -27,7 +27,7 @@
<configuration>
<properties>
<xml fileName="${basedir}/src/test/conf/archiva.xml"
- config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/>
+ config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/>
</properties>
</configuration>
</component>
diff --git a/archiva-site/src/site/apt/guides/configuration.apt b/archiva-site/src/site/apt/guides/configuration.apt
new file mode 100644
index 000000000..c307dff93
--- /dev/null
+++ b/archiva-site/src/site/apt/guides/configuration.apt
@@ -0,0 +1,63 @@
+ ------
+ Archiva Configuration
+ ------
+ The Maven Team
+ ------
+ 8 March 2007
+ ------
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/guides/mini/guide-apt-format.html
+
+Archiva Configuration
+
+* Web Configuration
+
+ Archiva can be fully configured from the web interface (with the exception of the {{{security-configuration.html} security properties, presently}}).
+
+ ...
+
+~~TODO: more details needed, but I wanted to get this started
+
+* File system configuration
+
+ While Archiva can be fully configred by the web interface, the configuration will be saved to the file system and can be edited from there if needed.
+
+ Archiva's configuration is loaded from the following files, in order of most precedent:
+
+ * <<<~/.m2/archiva.xml>>>
+
+ * <<<$ARCHIVA_BASE/conf/archiva.xml>>>
+
+ * <<<$ARCHIVA_HOME/conf/archiva.xml>>>
+
+ When Archiva saves it's configuration, all configuration is stored to a single file. The file chosen is by the following rules:
+
+ * If <<<~/.m2/archiva.xml>>> exists, it is saved there
+
+ * Otherwise, it is saved to <<<$ARCHIVA_BASE/conf/archiva.xml>>>, regardless of whether it previously existed.
+
+ The configuration will never be saved in <<<$ARCHIVA_HOME>>>.
+
+ Note that the configuration can be edited, but only when Archiva is not running as it will not reload a changed configuration file, and will save over it
+ if something is changed in the web interface.
+
+~~TODO: format?
+
diff --git a/archiva-site/src/site/apt/guides/security-configuration.apt b/archiva-site/src/site/apt/guides/security-configuration.apt
index 8c5876103..6c94918b6 100644
--- a/archiva-site/src/site/apt/guides/security-configuration.apt
+++ b/archiva-site/src/site/apt/guides/security-configuration.apt
@@ -39,8 +39,6 @@ Archiva Security Configuration
* <<<$ARCHIVA_HOME/conf/security.properties>>>
- * <<<$ARCHIVA_HOME/apps/archiva/conf/security.properties>>>
-
[]
(In the above list, <<<~>>> is the home directory of the user who is running
diff --git a/archiva-site/src/site/site.xml b/archiva-site/src/site/site.xml
index b2d1b5567..9c71480ce 100644
--- a/archiva-site/src/site/site.xml
+++ b/archiva-site/src/site/site.xml
@@ -30,6 +30,7 @@
<item name="FAQ" href="http://docs.codehaus.org/display/MAVENUSER/Archiva+FAQ"/>
<item name="Maven Configuration" href="/guides/getting-started/maven-configuration.html"/>
<item name="Security Configuration" href="/guides/security-configuration.html"/>
+ <item name="Other Configuration" href="/guides/configuration.html"/>
<item name="Developing" href="/guides/developing/index.html"/>
</menu>
diff --git a/archiva-webapp/pom.xml b/archiva-webapp/pom.xml
index 31de09233..ac94a47e9 100644
--- a/archiva-webapp/pom.xml
+++ b/archiva-webapp/pom.xml
@@ -340,6 +340,24 @@
</instrumentation>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <copy todir="${project.build.directory}/appserver-base">
+ <fileset dir="src/appserver-base" />
+ </copy>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</project>
diff --git a/archiva-webapp/src/appserver-base/conf/archiva.xml b/archiva-webapp/src/appserver-base/conf/archiva.xml
new file mode 100644
index 000000000..9afb83352
--- /dev/null
+++ b/archiva-webapp/src/appserver-base/conf/archiva.xml
@@ -0,0 +1 @@
+<configuration />
diff --git a/archiva-webapp/src/main/resources/META-INF/plexus/application.xml b/archiva-webapp/src/main/resources/META-INF/plexus/application.xml
index 9b0d313bf..e6725c0a6 100644
--- a/archiva-webapp/src/main/resources/META-INF/plexus/application.xml
+++ b/archiva-webapp/src/main/resources/META-INF/plexus/application.xml
@@ -29,8 +29,8 @@
<properties>
<system/>
<jndi prefix="java:comp/env" config-optional="true"/>
- <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva"
- config-at="org.apache.maven.archiva" config-forceCreate="true"/>
+ <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva.user"
+ config-at="org.apache.maven.archiva" />
<xml fileName="${user.home}/.m2/shared.xml" config-optional="true"
config-name="org.apache.maven.shared.app" config-at="org.apache.maven.shared.app"
config-forceCreate="true"/>
@@ -38,7 +38,7 @@
config-at="org.codehaus.plexus.security"/>
<properties fileName="${user.home}/.m2/archiva.properties" config-optional="true"
config-at="org.codehaus.plexus.security"/>
- <xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true"
+ <xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva.base"
config-at="org.apache.maven.archiva"/>
<xml fileName="${appserver.base}/conf/common.xml" config-optional="true"/>
<properties fileName="${appserver.base}/conf/security.properties" config-optional="true"