git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@515991 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-0.9-alpha-1
@@ -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; | |||
} | |||
@@ -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 | |||
{ |
@@ -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> |
@@ -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 --> |
@@ -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> |
@@ -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? | |||
@@ -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 |
@@ -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> | |||
@@ -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> |
@@ -0,0 +1 @@ | |||
<configuration /> |
@@ -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" |