aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2018-10-25 22:04:55 +0200
committerMartin Stockhammer <martin_s@apache.org>2018-10-25 22:04:55 +0200
commitc069d160f92e67669150a376fec6661025b2d4b8 (patch)
treea89d12e2a07605eec6c32a681bf77df99e7be98f /archiva-modules
parente45634e2c9bedbf924cbd23a1e60b0ae9b8f3d56 (diff)
downloadarchiva-c069d160f92e67669150a376fec6661025b2d4b8.tar.gz
archiva-c069d160f92e67669150a376fec6661025b2d4b8.zip
Adding environment variable for user config file
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java19
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml10
2 files changed, 18 insertions, 11 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
index a8dddadc5..cd1635d6b 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
+++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java
@@ -22,6 +22,7 @@ package org.apache.archiva.configuration;
import org.apache.archiva.redback.components.registry.RegistryException;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -326,10 +327,20 @@ public class ArchivaConfigurationTest
{
DefaultArchivaConfiguration archivaConfiguration =
(DefaultArchivaConfiguration) lookup( ArchivaConfiguration.class, "default" );
+ String expectedFile = System.getProperty( "user.home" ) + "/.m2/archiva.xml";
+ String systemFile = System.getProperty(ArchivaConfiguration.USER_CONFIG_PROPERTY);
+ if (StringUtils.isNotEmpty( systemFile )) {
+ expectedFile = systemFile;
+ } else
+ {
+ String envFile = System.getenv( ArchivaConfiguration.USER_CONFIG_ENVVAR );
+ if ( StringUtils.isNotEmpty( envFile ) )
+ expectedFile = envFile;
+ }
archivaConfiguration.reload();
- assertEquals( System.getProperty( "user.home" ) + "/.m2/archiva.xml",
+ assertEquals( expectedFile,
archivaConfiguration.getUserConfigFilename() );
assertEquals( System.getProperty( "appserver.base", "${appserver.base}" ) + "/conf/archiva.xml",
archivaConfiguration.getAltConfigFilename() );
@@ -496,6 +507,8 @@ public class ArchivaConfigurationTest
public void testLoadConfigurationFromInvalidBothLocationsOnDisk()
throws Exception
{
+ String propFile = System.getProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY );
+ System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, "${basedir}/target/*intentionally:invalid*/.m2/archiva-user.xml" );
ArchivaConfiguration archivaConfiguration =
lookup( ArchivaConfiguration.class, "test-not-allowed-to-write-to-both" );
Configuration config = archivaConfiguration.getConfiguration();
@@ -509,6 +522,10 @@ public class ArchivaConfigurationTest
{
/* expected exception */
}
+ if (propFile!=null)
+ {
+ System.setProperty( ArchivaConfiguration.USER_CONFIG_PROPERTY, propFile );
+ }
}
@Test
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
index 8fe71455f..9071317e9 100644
--- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
+++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml
@@ -77,16 +77,6 @@
<configuration>
<system/>
<jndi prefix="java:comp/env" config-optional="true"/>
- <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true"
- config-name="org.apache.archiva.user"
- config-at="org.apache.archiva"/>
- <xml fileName="${user.home}/.m2/shared.xml" config-optional="true"
- config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app"
- config-forceCreate="true"/>
- <properties fileName="${user.home}/.m2/security.properties" config-optional="true"
- config-at="org.apache.archiva.redback"/>
- <properties fileName="${user.home}/.m2/archiva.properties" config-optional="true"
- config-at="org.apache.archiva.redback"/>
<xml fileName="${appserver.base}/conf/archiva.xml" config-optional="true"
config-name="org.apache.archiva.base"
config-at="org.apache.archiva"/>