mirror of https://github.com/apache/archiva.git
PR: MRM-107
Removed classes from maven-proxy that may not be required at all. git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@386036 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e6c475550f
commit
d3e88a986a
|
@ -1,50 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2003-2004 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 java.io.File;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Strips file:/// off the front of the configured URL and uses that to find files locally.
|
|
||||||
*
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public class FileRepoConfiguration
|
|
||||||
extends RepoConfiguration
|
|
||||||
{
|
|
||||||
private final String basePath;
|
|
||||||
|
|
||||||
public FileRepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail,
|
|
||||||
boolean cacheFailures, long cachePeriod )
|
|
||||||
{
|
|
||||||
super( key, url, description, copy, hardFail, cacheFailures, cachePeriod );
|
|
||||||
basePath = url.substring( 8 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBasePath()
|
|
||||||
{
|
|
||||||
return basePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a relative path, returns the absolute file in the repository
|
|
||||||
*/
|
|
||||||
public File getLocalFile( String path )
|
|
||||||
{
|
|
||||||
return new File( basePath + path );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public class GlobalRepoConfiguration
|
|
||||||
extends FileRepoConfiguration
|
|
||||||
{
|
|
||||||
public GlobalRepoConfiguration( String basePath )
|
|
||||||
{
|
|
||||||
super( "global", "file:///" + basePath, "Global Repository", false, true, false, 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,64 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2003-2004 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public class HttpRepoConfiguration
|
|
||||||
extends RepoConfiguration
|
|
||||||
{
|
|
||||||
private final String username;
|
|
||||||
|
|
||||||
private final String password;
|
|
||||||
|
|
||||||
private final MavenProxyConfiguration proxy;
|
|
||||||
|
|
||||||
public HttpRepoConfiguration( String key, String url, String description, String username, String password,
|
|
||||||
boolean hardFail, MavenProxyConfiguration proxy, boolean cacheFailures,
|
|
||||||
long cachePeriod )
|
|
||||||
{
|
|
||||||
super( key, url, description, true, hardFail, cacheFailures, cachePeriod );
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
this.proxy = proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getPassword()
|
|
||||||
{
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getUsername()
|
|
||||||
{
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public MavenProxyConfiguration getProxy()
|
|
||||||
{
|
|
||||||
return proxy;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Immutable.
|
|
||||||
*
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public class MavenProxyConfiguration
|
|
||||||
{
|
|
||||||
private final String key;
|
|
||||||
|
|
||||||
private final String host;
|
|
||||||
|
|
||||||
private final int port;
|
|
||||||
|
|
||||||
private final String username;
|
|
||||||
|
|
||||||
private final String password;
|
|
||||||
|
|
||||||
public MavenProxyConfiguration( String key, String host, int port, String username, String password )
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
this.host = host;
|
|
||||||
this.port = port;
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHost()
|
|
||||||
{
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey()
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword()
|
|
||||||
{
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort()
|
|
||||||
{
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername()
|
|
||||||
{
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,67 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
import org.apache.maven.repository.proxy.repository.ProxyRepository;
|
|
||||||
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Edwin Punzalan
|
|
||||||
*/
|
|
||||||
public class MavenProxyConfigurationReader
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Uses maven-proxy classes to read a maven-proxy properties configuration
|
|
||||||
*
|
|
||||||
* @param mavenProxyConfigurationFile The location of the maven-proxy configuration file
|
|
||||||
* @throws ValidationException When a problem occured while processing the properties file
|
|
||||||
* @throws java.io.IOException When a problem occured while reading the property file
|
|
||||||
*/
|
|
||||||
public ProxyConfiguration loadMavenProxyConfiguration( File mavenProxyConfigurationFile )
|
|
||||||
throws ValidationException, IOException
|
|
||||||
{
|
|
||||||
ProxyConfiguration configuration = new ProxyConfiguration();
|
|
||||||
|
|
||||||
MavenProxyPropertyLoader loader = new MavenProxyPropertyLoader();
|
|
||||||
RetrievalComponentConfiguration rcc = loader.load( new FileInputStream( mavenProxyConfigurationFile ) );
|
|
||||||
|
|
||||||
configuration.setRepositoryCachePath( rcc.getLocalStore() );
|
|
||||||
|
|
||||||
List repoList = new ArrayList();
|
|
||||||
for ( Iterator repos = rcc.getRepos().iterator(); repos.hasNext(); )
|
|
||||||
{
|
|
||||||
RepoConfiguration repoConfig = (RepoConfiguration) repos.next();
|
|
||||||
|
|
||||||
//skip local store repo
|
|
||||||
if ( !repoConfig.getKey().equals( "global" ) )
|
|
||||||
{
|
|
||||||
ProxyRepository repo = new ProxyRepository( repoConfig.getKey(), repoConfig.getUrl(), new DefaultRepositoryLayout() );
|
|
||||||
repo.setCacheFailures( repoConfig.getCacheFailures() );
|
|
||||||
repo.setCachePeriod( repoConfig.getCachePeriod() );
|
|
||||||
repo.setHardfail( repoConfig.getHardFail() );
|
|
||||||
|
|
||||||
if ( repoConfig instanceof HttpRepoConfiguration )
|
|
||||||
{
|
|
||||||
HttpRepoConfiguration httpRepo = (HttpRepoConfiguration) repoConfig;
|
|
||||||
MavenProxyConfiguration httpProxy = httpRepo.getProxy();
|
|
||||||
//todo put into the configuration the proxy
|
|
||||||
if ( httpProxy != null )
|
|
||||||
{
|
|
||||||
repo.setProxied( true );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repoList.add( repo );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configuration.setRepositories( repoList );
|
|
||||||
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,9 +16,14 @@ package org.apache.maven.repository.proxy.configuration;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
|
||||||
|
import org.apache.maven.repository.proxy.repository.ProxyRepository;
|
||||||
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -30,113 +35,57 @@ import java.util.StringTokenizer;
|
||||||
*/
|
*/
|
||||||
public class MavenProxyPropertyLoader
|
public class MavenProxyPropertyLoader
|
||||||
{
|
{
|
||||||
|
private static final String REPO_LOCAL_STORE = "repo.local.store";
|
||||||
|
|
||||||
public static final String REPO_LOCAL_STORE = "repo.local.store";
|
private static final String PROXY_LIST = "proxy.list";
|
||||||
|
|
||||||
public static final String REPO_CUSTOM_STORE = "repo.custom.store";
|
private static final String REPO_LIST = "repo.list";
|
||||||
|
|
||||||
public static final String PORT = "port";
|
public ProxyConfiguration load( Properties props )
|
||||||
|
|
||||||
public static final String SNAPSHOT_UPDATE = "snapshot.update";
|
|
||||||
|
|
||||||
public static final String SNAPSHOT_CACHE_FAILURES = "snapshot.cache.failures";
|
|
||||||
|
|
||||||
public static final String METADATA_UPDATE = "metadata.update";
|
|
||||||
|
|
||||||
public static final String POM_UPDATE = "pom.update";
|
|
||||||
|
|
||||||
public static final int DEFAULT_PORT = 4321;
|
|
||||||
|
|
||||||
public static final String LAST_MODIFIED_DATE_FORMAT = "lastModifiedDateFormat";
|
|
||||||
|
|
||||||
public static final String DEFAULT_LAST_MODIFIED_DATE_FORMAT = null;
|
|
||||||
|
|
||||||
public static final String BROWSABLE = "browsable";
|
|
||||||
|
|
||||||
public static final String SEARCHABLE = "searchable";
|
|
||||||
|
|
||||||
public static final String STYLESHEET = "stylesheet";
|
|
||||||
|
|
||||||
public static final String BGCOLOR = "css.bgColor";
|
|
||||||
|
|
||||||
public static final String BGCOLORHIGHLIGHT = "css.bgColorHighlight";
|
|
||||||
|
|
||||||
public static final String ROWCOLOR = "css.rowColor";
|
|
||||||
|
|
||||||
public static final String ROWCOLORHIGHLIGHT = "css.rowColorHighlight";
|
|
||||||
|
|
||||||
public static final String PREFIX = "prefix";
|
|
||||||
|
|
||||||
private static final String SERVERNAME = "serverName";
|
|
||||||
|
|
||||||
public RetrievalComponentConfiguration load( Properties props )
|
|
||||||
throws ValidationException
|
throws ValidationException
|
||||||
{
|
{
|
||||||
RetrievalComponentConfiguration rcc = new RetrievalComponentConfiguration();
|
ProxyConfiguration config = new ProxyConfiguration();
|
||||||
|
|
||||||
String localStore = getMandatoryProperty( props, REPO_LOCAL_STORE );
|
config.setLayout( "default" );
|
||||||
GlobalRepoConfiguration globalRepo = new GlobalRepoConfiguration( localStore );
|
|
||||||
rcc.setLocalStore( localStore );
|
|
||||||
rcc.addRepo( globalRepo );
|
|
||||||
|
|
||||||
if ( props.getProperty( PORT ) == null )
|
config.setRepositoryCachePath( getMandatoryProperty( props, REPO_LOCAL_STORE ) );
|
||||||
{
|
|
||||||
rcc.setPort( DEFAULT_PORT );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
rcc.setPort( Integer.parseInt( props.getProperty( PORT ) ) );
|
|
||||||
}
|
|
||||||
catch ( NumberFormatException ex )
|
|
||||||
{
|
|
||||||
throw new ValidationException( "Property " + PORT + " must be a integer" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rcc.setSnapshotUpdate( Boolean.valueOf( getMandatoryProperty( props, SNAPSHOT_UPDATE ) ).booleanValue() );
|
{//just get the first proxy and break
|
||||||
rcc.setMetaDataUpdate(
|
String propertyList = props.getProperty( PROXY_LIST );
|
||||||
Boolean.valueOf( getOptionalProperty( props, METADATA_UPDATE, "true" ) ).booleanValue() );
|
|
||||||
rcc.setPOMUpdate( Boolean.valueOf( getOptionalProperty( props, POM_UPDATE, "false" ) ).booleanValue() );
|
|
||||||
|
|
||||||
rcc.setBrowsable( Boolean.valueOf( getMandatoryProperty( props, BROWSABLE ) ).booleanValue() );
|
|
||||||
rcc.setSearchable( Boolean.valueOf( getOptionalProperty( props, SEARCHABLE, "true" ) ).booleanValue() );
|
|
||||||
rcc.setServerName( props.getProperty( SERVERNAME ) );
|
|
||||||
rcc.setPrefix( getMandatoryProperty( props, PREFIX ) );
|
|
||||||
rcc.setLastModifiedDateFormat( props.getProperty( LAST_MODIFIED_DATE_FORMAT ) );
|
|
||||||
rcc.setStylesheet( getOptionalProperty( props, STYLESHEET, null ) );
|
|
||||||
rcc.setBgColor( getOptionalProperty( props, BGCOLOR, "#14B" ) );
|
|
||||||
rcc.setBgColorHighlight( getOptionalProperty( props, BGCOLORHIGHLIGHT, "#9BF" ) );
|
|
||||||
rcc.setRowColor( getOptionalProperty( props, ROWCOLOR, "#CCF" ) );
|
|
||||||
rcc.setRowColorHighlight( getOptionalProperty( props, ROWCOLORHIGHLIGHT, "#DDF" ) );
|
|
||||||
|
|
||||||
if ( rcc.getPrefix().length() == 0 )
|
|
||||||
{
|
|
||||||
//System.err.println( "Using an empty 'prefix' is deprecated behaviour. Please set a prefix." );
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
String propertyList = props.getProperty( "proxy.list" );
|
|
||||||
if ( propertyList != null )
|
if ( propertyList != null )
|
||||||
{
|
{
|
||||||
StringTokenizer tok = new StringTokenizer( propertyList, "," );
|
StringTokenizer tok = new StringTokenizer( propertyList, "," );
|
||||||
while ( tok.hasMoreTokens() )
|
while ( tok.hasMoreTokens() )
|
||||||
{
|
{
|
||||||
String key = tok.nextToken();
|
String key = tok.nextToken();
|
||||||
String host = getMandatoryProperty( props, "proxy." + key + ".host" );
|
if ( StringUtils.isNotEmpty( key ) )
|
||||||
int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) );
|
{
|
||||||
// the username and password isn't required
|
String host = getMandatoryProperty( props, "proxy." + key + ".host" );
|
||||||
String username = props.getProperty( "proxy." + key + ".username" );
|
int port = Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) );
|
||||||
String password = props.getProperty( "proxy." + key + ".password" );
|
|
||||||
MavenProxyConfiguration pc = new MavenProxyConfiguration( key, host, port, username, password );
|
// the username and password isn't required
|
||||||
rcc.addProxy( pc );
|
String username = props.getProperty( "proxy." + key + ".username" );
|
||||||
|
String password = props.getProperty( "proxy." + key + ".password" );
|
||||||
|
|
||||||
|
if ( StringUtils.isNotEmpty( username ) )
|
||||||
|
{
|
||||||
|
config.setHttpProxy( host, port, username, password );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.setHttpProxy( host, port );
|
||||||
|
}
|
||||||
|
|
||||||
|
//accept only one proxy configuration
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
List repositories = new ArrayList();
|
||||||
String repoList = getMandatoryProperty( props, "repo.list" );
|
{ //get the remote repository list
|
||||||
|
String repoList = getMandatoryProperty( props, REPO_LIST );
|
||||||
|
|
||||||
StringTokenizer tok = new StringTokenizer( repoList, "," );
|
StringTokenizer tok = new StringTokenizer( repoList, "," );
|
||||||
while ( tok.hasMoreTokens() )
|
while ( tok.hasMoreTokens() )
|
||||||
|
@ -145,97 +94,39 @@ public class MavenProxyPropertyLoader
|
||||||
|
|
||||||
Properties repoProps = getSubset( props, "repo." + key + "." );
|
Properties repoProps = getSubset( props, "repo." + key + "." );
|
||||||
String url = getMandatoryProperty( props, "repo." + key + ".url" );
|
String url = getMandatoryProperty( props, "repo." + key + ".url" );
|
||||||
// the username, password and proxy are not mandatory
|
|
||||||
String username = repoProps.getProperty( "username" );
|
|
||||||
String password = repoProps.getProperty( "password" );
|
|
||||||
String description = repoProps.getProperty( "description" );
|
|
||||||
String proxyKey = repoProps.getProperty( "proxy" );
|
String proxyKey = repoProps.getProperty( "proxy" );
|
||||||
|
|
||||||
Boolean cacheFailures = Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) );
|
boolean cacheFailures = Boolean.valueOf( repoProps.getProperty( "cache.failures", "false" ) ).booleanValue();
|
||||||
Long cachePeriod = Long.valueOf( repoProps.getProperty( "cache.period", "0" ) );
|
boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) ).booleanValue();
|
||||||
Boolean hardFail = Boolean.valueOf( repoProps.getProperty( "hardfail", "true" ) );
|
long cachePeriod = Long.parseLong( repoProps.getProperty( "cache.period", "0" ) );
|
||||||
|
|
||||||
MavenProxyConfiguration proxy = null;
|
ProxyRepository repository =
|
||||||
if ( proxyKey != null )
|
new ProxyRepository( key, url, new DefaultRepositoryLayout(), cacheFailures, cachePeriod );
|
||||||
|
|
||||||
|
repository.setHardfail( hardFail );
|
||||||
|
|
||||||
|
if ( StringUtils.isNotEmpty( proxyKey ) )
|
||||||
{
|
{
|
||||||
proxy = rcc.getProxy( proxyKey );
|
repository.setProxied( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( description == null || description.trim().length() == 0 )
|
repositories.add( repository );
|
||||||
{
|
|
||||||
description = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
RepoConfiguration rc = null;
|
|
||||||
|
|
||||||
if ( url.startsWith( "http://" ) )
|
|
||||||
{
|
|
||||||
rc = new HttpRepoConfiguration( key, url, description, username, password, hardFail.booleanValue(),
|
|
||||||
proxy, cacheFailures.booleanValue(), cachePeriod.longValue() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( url.startsWith( "file:///" ) )
|
|
||||||
{
|
|
||||||
boolean copy = "true".equalsIgnoreCase( repoProps.getProperty( "copy" ) );
|
|
||||||
rc = new FileRepoConfiguration( key, url, description, copy, hardFail.booleanValue(), cacheFailures
|
|
||||||
.booleanValue(), cachePeriod.longValue() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( rc == null )
|
|
||||||
{
|
|
||||||
throw new ValidationException( "Unknown upstream repository type: " + url );
|
|
||||||
}
|
|
||||||
|
|
||||||
rcc.addRepo( rc );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validateDirectories( rcc );
|
config.setRepositories( repositories );
|
||||||
validateLocalRepo( rcc );
|
|
||||||
validateRemoteRepo( rcc );
|
|
||||||
return rcc;
|
|
||||||
|
|
||||||
|
validateDirectories( config );
|
||||||
|
validateRemoteRepo( config );
|
||||||
|
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void validateRemoteRepo( ProxyConfiguration configuration )
|
||||||
* Checks to make sure a specific value is set
|
|
||||||
*
|
|
||||||
* @throws ValidationException if value is null
|
|
||||||
*/
|
|
||||||
private String checkSet( String value, String propertyName )
|
|
||||||
throws ValidationException
|
|
||||||
{
|
|
||||||
if ( value == null )
|
|
||||||
{
|
|
||||||
throw new ValidationException( "Missing property '" + propertyName + "'" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateLocalRepo( RetrievalComponentConfiguration rcc )
|
|
||||||
throws ValidationException
|
|
||||||
{
|
|
||||||
//Verify local repository set
|
|
||||||
String tmp = checkSet( rcc.getLocalStore(), MavenProxyPropertyLoader.REPO_LOCAL_STORE );
|
|
||||||
|
|
||||||
File file = new File( tmp );
|
|
||||||
if ( !file.exists() )
|
|
||||||
{
|
|
||||||
throw new ValidationException( "The local repository doesn't exist: " + file.getAbsolutePath() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !file.isDirectory() )
|
|
||||||
{
|
|
||||||
throw new ValidationException( "The local repository must be a directory: " + file.getAbsolutePath() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateRemoteRepo( RetrievalComponentConfiguration rcc )
|
|
||||||
throws ValidationException
|
throws ValidationException
|
||||||
{
|
{
|
||||||
//Verify remote repository set
|
//Verify remote repository set
|
||||||
//only warn if missing
|
//only warn if missing
|
||||||
if ( rcc.getRepos().size() < 1 )
|
if ( configuration.getRepositories().size() < 1 )
|
||||||
{
|
{
|
||||||
throw new ValidationException( "At least one remote repository must be configured." );
|
throw new ValidationException( "At least one remote repository must be configured." );
|
||||||
}
|
}
|
||||||
|
@ -258,7 +149,7 @@ public class MavenProxyPropertyLoader
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RetrievalComponentConfiguration load( InputStream is )
|
public ProxyConfiguration load( InputStream is )
|
||||||
throws IOException, ValidationException
|
throws IOException, ValidationException
|
||||||
{
|
{
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
|
@ -279,35 +170,21 @@ public class MavenProxyPropertyLoader
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOptionalProperty( Properties props, String key, String defaultValue )
|
private void validateDirectories( ProxyConfiguration configuration )
|
||||||
{
|
|
||||||
final String value = props.getProperty( key );
|
|
||||||
|
|
||||||
if ( value == null )
|
|
||||||
{
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateDirectories( RetrievalComponentConfiguration rcc )
|
|
||||||
throws ValidationException
|
throws ValidationException
|
||||||
{
|
{
|
||||||
File f = new File( rcc.getLocalStore() );
|
File f = new File( configuration.getRepositoryCachePath() );
|
||||||
if ( !f.exists() )
|
if ( !f.exists() )
|
||||||
{
|
{
|
||||||
throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() );
|
throw new ValidationException( "Specified directory does not exist: " + f.getAbsolutePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
List repos = rcc.getRepos();
|
for ( Iterator repos = configuration.getRepositories().iterator(); repos.hasNext(); )
|
||||||
for ( Iterator iter = repos.iterator(); iter.hasNext(); )
|
|
||||||
{
|
{
|
||||||
RepoConfiguration repo = (RepoConfiguration) iter.next();
|
ProxyRepository repo = (ProxyRepository) repos.next();
|
||||||
if ( repo instanceof FileRepoConfiguration )
|
if ( repo.getUrl().startsWith( "file://" ) )
|
||||||
{
|
{
|
||||||
FileRepoConfiguration fileRepo = (FileRepoConfiguration) repo;
|
File f2 = new File( repo.getBasedir() );
|
||||||
File f2 = new File( fileRepo.getBasePath() );
|
|
||||||
if ( !f2.exists() )
|
if ( !f2.exists() )
|
||||||
{
|
{
|
||||||
throw new ValidationException( "Specified directory does not exist: " + f2.getAbsolutePath() );
|
throw new ValidationException( "Specified directory does not exist: " + f2.getAbsolutePath() );
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2005-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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Edwin Punzalan
|
|
||||||
*/
|
|
||||||
public class MavenProxyRepoConfiguration
|
|
||||||
extends RepoConfiguration
|
|
||||||
{
|
|
||||||
public MavenProxyRepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail,
|
|
||||||
boolean cacheFailures, long cachePeriod )
|
|
||||||
{
|
|
||||||
super( key, url, description, copy, hardFail, cacheFailures, cachePeriod );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,110 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2003-2004 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.codehaus.plexus.logging.AbstractLogEnabled;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Immutable.
|
|
||||||
* <p/>
|
|
||||||
* hardfail - if a repository is set to hard fail, then the download engine will terminate the whole download
|
|
||||||
* process (with a status 500) if any of the repositories have unexpected errors.
|
|
||||||
* <p/>
|
|
||||||
* if a repository expects an error - eg. 400 (not found) - then it is not required to terminate the
|
|
||||||
* download process.
|
|
||||||
*
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public abstract class RepoConfiguration
|
|
||||||
extends AbstractLogEnabled
|
|
||||||
{
|
|
||||||
private final String key;
|
|
||||||
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
private final String url;
|
|
||||||
|
|
||||||
private final boolean copy;
|
|
||||||
|
|
||||||
private final boolean hardFail;
|
|
||||||
|
|
||||||
private final boolean cacheFailures;
|
|
||||||
|
|
||||||
private final long cachePeriod;
|
|
||||||
|
|
||||||
public RepoConfiguration( String key, String url, String description, boolean copy, boolean hardFail,
|
|
||||||
boolean cacheFailures, long cachePeriod )
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
this.url = url;
|
|
||||||
this.description = description;
|
|
||||||
this.copy = copy;
|
|
||||||
this.hardFail = hardFail;
|
|
||||||
this.cacheFailures = cacheFailures;
|
|
||||||
this.cachePeriod = cachePeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getUrl()
|
|
||||||
{
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public String getKey()
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If a file repository is set to "copy" mode, it will copy the found files into
|
|
||||||
* the main repository store.
|
|
||||||
*/
|
|
||||||
public boolean getCopy()
|
|
||||||
{
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription()
|
|
||||||
{
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getHardFail()
|
|
||||||
{
|
|
||||||
return hardFail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getCacheFailures()
|
|
||||||
{
|
|
||||||
return cacheFailures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCachePeriod()
|
|
||||||
{
|
|
||||||
return cachePeriod;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Repo[" + getKey() + "]";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,311 +0,0 @@
|
||||||
package org.apache.maven.repository.proxy.configuration;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright 2005-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 java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Ben Walding
|
|
||||||
*/
|
|
||||||
public class RetrievalComponentConfiguration
|
|
||||||
{
|
|
||||||
private final Map proxies = new HashMap();
|
|
||||||
|
|
||||||
private final List repos = new ArrayList();
|
|
||||||
|
|
||||||
private String localStore;
|
|
||||||
|
|
||||||
private String serverName;
|
|
||||||
|
|
||||||
private String bgColor;
|
|
||||||
|
|
||||||
private String bgColorHighlight;
|
|
||||||
|
|
||||||
private String rowColor;
|
|
||||||
|
|
||||||
private String rowColorHighlight;
|
|
||||||
|
|
||||||
private String stylesheet;
|
|
||||||
|
|
||||||
private boolean searchable;
|
|
||||||
|
|
||||||
private boolean browsable;
|
|
||||||
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
private boolean snapshotUpdate;
|
|
||||||
|
|
||||||
private boolean metaDataUpdate;
|
|
||||||
|
|
||||||
private boolean pomUpdate;
|
|
||||||
|
|
||||||
private String lastModifiedDateFormat;
|
|
||||||
|
|
||||||
public String getPrefix()
|
|
||||||
{
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPrefix( String prefix )
|
|
||||||
{
|
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isBrowsable()
|
|
||||||
{
|
|
||||||
return browsable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param browsable
|
|
||||||
*/
|
|
||||||
public void setBrowsable( boolean browsable )
|
|
||||||
{
|
|
||||||
this.browsable = browsable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort()
|
|
||||||
{
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort( int port )
|
|
||||||
{
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getLocalStore()
|
|
||||||
{
|
|
||||||
return localStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param localStore
|
|
||||||
*/
|
|
||||||
public void setLocalStore( String localStore )
|
|
||||||
{
|
|
||||||
this.localStore = localStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProxy( MavenProxyConfiguration pc )
|
|
||||||
{
|
|
||||||
proxies.put( pc.getKey(), pc );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeProxy( String key )
|
|
||||||
{
|
|
||||||
proxies.remove( key );
|
|
||||||
}
|
|
||||||
|
|
||||||
public MavenProxyConfiguration getProxy( String key )
|
|
||||||
{
|
|
||||||
return (MavenProxyConfiguration) proxies.get( key );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* There is no specific order to proxy configuration.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List getProxies()
|
|
||||||
{
|
|
||||||
return new ArrayList( proxies.values() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addRepo( RepoConfiguration repo )
|
|
||||||
{
|
|
||||||
repos.add( repo );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getRepos()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList( repos );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerName()
|
|
||||||
{
|
|
||||||
return serverName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setServerName( String serverName )
|
|
||||||
{
|
|
||||||
this.serverName = serverName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSnapshotUpdate( boolean snapshotUpdate )
|
|
||||||
{
|
|
||||||
this.snapshotUpdate = snapshotUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSnapshotUpdate()
|
|
||||||
{
|
|
||||||
return snapshotUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMetaDataUpdate( boolean metaDataUpdate )
|
|
||||||
{
|
|
||||||
this.metaDataUpdate = metaDataUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getMetaDataUpdate()
|
|
||||||
{
|
|
||||||
return metaDataUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPOMUpdate( boolean pomUpdate )
|
|
||||||
{
|
|
||||||
this.pomUpdate = pomUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getPOMUpdate()
|
|
||||||
{
|
|
||||||
return pomUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLastModifiedDateFormat()
|
|
||||||
{
|
|
||||||
return lastModifiedDateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastModifiedDateFormat( String lastModifiedDateFormat )
|
|
||||||
{
|
|
||||||
this.lastModifiedDateFormat = lastModifiedDateFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSearchable()
|
|
||||||
{
|
|
||||||
return searchable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSearchable( boolean searchable )
|
|
||||||
{
|
|
||||||
this.searchable = searchable;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the global repo configuration
|
|
||||||
*/
|
|
||||||
public GlobalRepoConfiguration getGlobalRepo()
|
|
||||||
{
|
|
||||||
for ( Iterator iter = repos.iterator(); iter.hasNext(); )
|
|
||||||
{
|
|
||||||
RepoConfiguration repo = (RepoConfiguration) iter.next();
|
|
||||||
if ( repo instanceof GlobalRepoConfiguration )
|
|
||||||
{
|
|
||||||
return (GlobalRepoConfiguration) repo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ThreadLocal dateFormatThreadLocal = new ThreadLocal()
|
|
||||||
{
|
|
||||||
protected synchronized Object initialValue()
|
|
||||||
{
|
|
||||||
DateFormat df;
|
|
||||||
|
|
||||||
if ( getLastModifiedDateFormat() == null || getLastModifiedDateFormat() == "" )
|
|
||||||
{
|
|
||||||
df = new SimpleDateFormat();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
df = new SimpleDateFormat( getLastModifiedDateFormat() );
|
|
||||||
}
|
|
||||||
|
|
||||||
df.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
|
||||||
return df;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves and casts the appropriate DateFormat object from a ThreadLocal
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public DateFormat getLastModifiedDateFormatForThread()
|
|
||||||
{
|
|
||||||
return (DateFormat) dateFormatThreadLocal.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBgColor()
|
|
||||||
{
|
|
||||||
return bgColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBgColor( String bgColor )
|
|
||||||
{
|
|
||||||
this.bgColor = bgColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBgColorHighlight()
|
|
||||||
{
|
|
||||||
return bgColorHighlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBgColorHighlight( String bgColorHighlight )
|
|
||||||
{
|
|
||||||
this.bgColorHighlight = bgColorHighlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStylesheet()
|
|
||||||
{
|
|
||||||
return stylesheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStylesheet( String stylesheet )
|
|
||||||
{
|
|
||||||
this.stylesheet = stylesheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRowColor()
|
|
||||||
{
|
|
||||||
return rowColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRowColor( String rowColor )
|
|
||||||
{
|
|
||||||
this.rowColor = rowColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRowColorHighlight()
|
|
||||||
{
|
|
||||||
return rowColorHighlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRowColorHighlight( String rowColorHighlight )
|
|
||||||
{
|
|
||||||
this.rowColorHighlight = rowColorHighlight;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -33,7 +33,7 @@ public class ProxyRepository
|
||||||
|
|
||||||
private boolean cacheFailures = false;
|
private boolean cacheFailures = false;
|
||||||
|
|
||||||
private boolean hardfail = false;
|
private boolean hardfail = true;
|
||||||
|
|
||||||
private boolean proxied = false;
|
private boolean proxied = false;
|
||||||
|
|
||||||
|
|
|
@ -1,144 +1,144 @@
|
||||||
################ GLOBAL SETTINGS
|
################ GLOBAL SETTINGS
|
||||||
# This is where maven-proxy stores files it has downloaded
|
# This is where maven-proxy stores files it has downloaded
|
||||||
repo.local.store=target
|
repo.local.store=target
|
||||||
|
|
||||||
#The port to listen on - not used if loaded as a webapp
|
#The port to listen on - not used if loaded as a webapp
|
||||||
port=9999
|
port=9999
|
||||||
|
|
||||||
#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour
|
#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour
|
||||||
#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using
|
#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using
|
||||||
#a prefix.
|
#a prefix.
|
||||||
#The repository will be shown at http://localhost:9999/repository/
|
#The repository will be shown at http://localhost:9999/repository/
|
||||||
#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change)
|
#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change)
|
||||||
# As maven doesn't like a trailing slash, this address shouldn't have one either.
|
# As maven doesn't like a trailing slash, this address shouldn't have one either.
|
||||||
prefix=repository
|
prefix=repository
|
||||||
|
|
||||||
#This is the simple date format used to display the last modified date while browsing the repository.
|
#This is the simple date format used to display the last modified date while browsing the repository.
|
||||||
lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss
|
lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss
|
||||||
|
|
||||||
################ SNAPSHOT HANDLING
|
################ SNAPSHOT HANDLING
|
||||||
#If you want the proxy to look for newer snapshots, set to true
|
#If you want the proxy to look for newer snapshots, set to true
|
||||||
snapshot.update=true
|
snapshot.update=true
|
||||||
|
|
||||||
################ M2 METADATA HANDLING
|
################ M2 METADATA HANDLING
|
||||||
#If you want the proxy to prevent looking for newer metadata, set to false (default is true)
|
#If you want the proxy to prevent looking for newer metadata, set to false (default is true)
|
||||||
#metadata.update=false
|
#metadata.update=false
|
||||||
|
|
||||||
################ M2 POM HANDLING
|
################ M2 POM HANDLING
|
||||||
#If you want the proxy to look for newer POMs, set to true (default is false)
|
#If you want the proxy to look for newer POMs, set to true (default is false)
|
||||||
pom.update=true
|
pom.update=true
|
||||||
|
|
||||||
################ PROMOTION HANDLING
|
################ PROMOTION HANDLING
|
||||||
# ***** NOT CURRENTLY IMPLEMENTED *****
|
# ***** NOT CURRENTLY IMPLEMENTED *****
|
||||||
#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It
|
#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It
|
||||||
# is designed to be used by "higher security installations" that do not want to acquire artifacts from
|
# is designed to be used by "higher security installations" that do not want to acquire artifacts from
|
||||||
# remote repositories without approval.
|
# remote repositories without approval.
|
||||||
#
|
#
|
||||||
#If promotion handling is enabled, then the proxy will not download remote artifacts without permission
|
#If promotion handling is enabled, then the proxy will not download remote artifacts without permission
|
||||||
# (local repositories with copy=false are considered to be local)
|
# (local repositories with copy=false are considered to be local)
|
||||||
#
|
#
|
||||||
#Permission to download is granted via the Promotion menu which will be enabled
|
#Permission to download is granted via the Promotion menu which will be enabled
|
||||||
# when promotion handling is enabled.
|
# when promotion handling is enabled.
|
||||||
#
|
#
|
||||||
#If promotion is false, artifacts are sourced from any repository as per normal.
|
#If promotion is false, artifacts are sourced from any repository as per normal.
|
||||||
#
|
#
|
||||||
#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using
|
#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using
|
||||||
# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive.
|
# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive.
|
||||||
##
|
##
|
||||||
promotion=false
|
promotion=false
|
||||||
|
|
||||||
################ WEB INTERFACE
|
################ WEB INTERFACE
|
||||||
# This defines the absolute URL the server should use to identify itself.
|
# This defines the absolute URL the server should use to identify itself.
|
||||||
# This can often be determined automatically, but we recommend you specify
|
# This can often be determined automatically, but we recommend you specify
|
||||||
# it explicitly to prevent problems during startup.
|
# it explicitly to prevent problems during startup.
|
||||||
# The prefix will be added to this for the actual repository
|
# The prefix will be added to this for the actual repository
|
||||||
# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository
|
# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository
|
||||||
serverName=http://localhost:9999
|
serverName=http://localhost:9999
|
||||||
|
|
||||||
#If true, the repository can be browsed
|
#If true, the repository can be browsed
|
||||||
browsable=true
|
browsable=true
|
||||||
|
|
||||||
#If true, the repository can be searched
|
#If true, the repository can be searched
|
||||||
searchable=true
|
searchable=true
|
||||||
|
|
||||||
#Not currently implemented. Will allow webdav access to the repository at some point.
|
#Not currently implemented. Will allow webdav access to the repository at some point.
|
||||||
webdav=true
|
webdav=true
|
||||||
|
|
||||||
#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only
|
#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only
|
||||||
#eg. /maven-proxy/style.css, http://www.example.com/style.css
|
#eg. /maven-proxy/style.css, http://www.example.com/style.css
|
||||||
stylesheet=/maven-proxy/style.css
|
stylesheet=/maven-proxy/style.css
|
||||||
|
|
||||||
#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
|
#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
|
||||||
#If a stylesheet is set, these are not used.
|
#If a stylesheet is set, these are not used.
|
||||||
bgColor=#14B
|
bgColor=#14B
|
||||||
bgColorHighlight=#94B
|
bgColorHighlight=#94B
|
||||||
|
|
||||||
#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
|
#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme.
|
||||||
#If a stylesheet is set, these are not used.
|
#If a stylesheet is set, these are not used.
|
||||||
rowColor=#CCF
|
rowColor=#CCF
|
||||||
rowColorHighlight=#DDF
|
rowColorHighlight=#DDF
|
||||||
|
|
||||||
|
|
||||||
################ PROXIES
|
################ PROXIES
|
||||||
#This is just a hack, it should auto discover them
|
#This is just a hack, it should auto discover them
|
||||||
proxy.list=one,two,three
|
proxy.list=one,two,three
|
||||||
|
|
||||||
#Unauthenticated proxy
|
#Unauthenticated proxy
|
||||||
proxy.one.host=proxy1.example.com
|
proxy.one.host=proxy1.example.com
|
||||||
proxy.one.port=3128
|
proxy.one.port=3128
|
||||||
|
|
||||||
#Authenticated proxy
|
#Authenticated proxy
|
||||||
proxy.two.host=proxy2.example.org
|
proxy.two.host=proxy2.example.org
|
||||||
proxy.two.port=80
|
proxy.two.port=80
|
||||||
proxy.two.username=username2
|
proxy.two.username=username2
|
||||||
proxy.two.password=password2
|
proxy.two.password=password2
|
||||||
|
|
||||||
#Authenticated proxy
|
#Authenticated proxy
|
||||||
proxy.three.host=proxy3.example.net
|
proxy.three.host=proxy3.example.net
|
||||||
proxy.three.port=3129
|
proxy.three.port=3129
|
||||||
proxy.three.username=username3
|
proxy.three.username=username3
|
||||||
proxy.three.password=password3
|
proxy.three.password=password3
|
||||||
|
|
||||||
|
|
||||||
################# REPOSITORIES
|
################# REPOSITORIES
|
||||||
#This is not just a hack, it specifies the order repositories should be checked
|
#This is not just a hack, it specifies the order repositories should be checked
|
||||||
#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/"
|
#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/"
|
||||||
repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com
|
repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com
|
||||||
|
|
||||||
#local-store
|
#local-store
|
||||||
# The local store represents a location that local jars you host can be located.
|
# The local store represents a location that local jars you host can be located.
|
||||||
# This could also be achieved by having a local http repository, but this is less cumbersome
|
# This could also be achieved by having a local http repository, but this is less cumbersome
|
||||||
repo.local-repo.url=file:///./target/remote-repo1
|
repo.local-repo.url=file://target
|
||||||
repo.local-repo.description=Super Secret Custom Repository
|
repo.local-repo.description=Super Secret Custom Repository
|
||||||
#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos
|
#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos
|
||||||
repo.local-repo.copy=false
|
repo.local-repo.copy=false
|
||||||
#If hardfail is true, any unexpected errors from the repository will cause
|
#If hardfail is true, any unexpected errors from the repository will cause
|
||||||
#the client download to fail (typically with a 500 error)
|
#the client download to fail (typically with a 500 error)
|
||||||
repo.local-repo.hardfail=true
|
repo.local-repo.hardfail=true
|
||||||
#Don't cache a file repository
|
#Don't cache a file repository
|
||||||
repo.local-repo.cache.period=0
|
repo.local-repo.cache.period=0
|
||||||
|
|
||||||
|
|
||||||
#www.ibiblio.org
|
#www.ibiblio.org
|
||||||
repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2
|
repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2
|
||||||
repo.www-ibiblio-org.description=www.ibiblio.org
|
repo.www-ibiblio-org.description=www.ibiblio.org
|
||||||
repo.www-ibiblio-org.proxy=one
|
repo.www-ibiblio-org.proxy=one
|
||||||
repo.www-ibiblio-org.hardfail=true
|
repo.www-ibiblio-org.hardfail=true
|
||||||
#Cache this repository for 1 hour
|
#Cache this repository for 1 hour
|
||||||
repo.www-ibiblio-org.cache.period=3600
|
repo.www-ibiblio-org.cache.period=3600
|
||||||
repo.www-ibiblio-org.cache.failures=true
|
repo.www-ibiblio-org.cache.failures=true
|
||||||
|
|
||||||
#dist.codehaus.org
|
#dist.codehaus.org
|
||||||
repo.dist-codehaus-org.url=http://dist.codehaus.org
|
repo.dist-codehaus-org.url=http://dist.codehaus.org
|
||||||
repo.dist-codehaus-org.proxy=two
|
repo.dist-codehaus-org.proxy=two
|
||||||
repo.dist-codehaus-org.hardfail=false
|
repo.dist-codehaus-org.hardfail=false
|
||||||
repo.dist-codehaus-org.cache.period=3600
|
repo.dist-codehaus-org.cache.period=3600
|
||||||
repo.dist-codehaus-org.cache.failures=true
|
repo.dist-codehaus-org.cache.failures=true
|
||||||
|
|
||||||
#private.example.com
|
#private.example.com
|
||||||
repo.private-example-com.url=http://private.example.com/internal
|
repo.private-example-com.url=http://private.example.com/internal
|
||||||
repo.private-example-com.description=Commercial In Confidence Repository
|
repo.private-example-com.description=Commercial In Confidence Repository
|
||||||
repo.private-example-com.username=username1
|
repo.private-example-com.username=username1
|
||||||
repo.private-example-com.password=password1
|
repo.private-example-com.password=password1
|
||||||
repo.private-example-com.proxy=three
|
repo.private-example-com.proxy=three
|
||||||
repo.private-example-com.cache.period=3600
|
repo.private-example-com.cache.period=3600
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
package org.apache.maven.repository.proxy.configuration;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2005-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.repository.proxy.repository.ProxyRepository;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
import org.codehaus.plexus.util.FileUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Edwin Punzalan
|
||||||
|
*/
|
||||||
|
public class MavenProxyPropertyLoaderTest
|
||||||
|
extends PlexusTestCase
|
||||||
|
{
|
||||||
|
public void testLoadValidMavenProxyConfiguration()
|
||||||
|
throws ValidationException, IOException
|
||||||
|
{
|
||||||
|
MavenProxyPropertyLoader loader = new MavenProxyPropertyLoader();
|
||||||
|
|
||||||
|
//must create the test directory bec configuration is using relative path which varies
|
||||||
|
FileUtils.mkdir( "target/remote-repo1" );
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
|
||||||
|
|
||||||
|
ProxyConfiguration config = loader.load( new FileInputStream( confFile ) );
|
||||||
|
|
||||||
|
assertTrue( "cache path changed", config.getRepositoryCachePath().endsWith( "target" ) );
|
||||||
|
|
||||||
|
assertEquals( "Count repositories", 4, config.getRepositories().size() );
|
||||||
|
|
||||||
|
int idx = 0;
|
||||||
|
for ( Iterator repos = config.getRepositories().iterator(); repos.hasNext(); )
|
||||||
|
{
|
||||||
|
idx++;
|
||||||
|
|
||||||
|
ProxyRepository repo = (ProxyRepository) repos.next();
|
||||||
|
|
||||||
|
//switch is made to check for ordering
|
||||||
|
switch ( idx )
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
assertEquals( "Repository name not as expected", "local-repo", repo.getKey() );
|
||||||
|
assertEquals( "Repository url does not match its name", "file://target",
|
||||||
|
repo.getUrl() );
|
||||||
|
assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() );
|
||||||
|
assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() );
|
||||||
|
assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2",
|
||||||
|
repo.getUrl() );
|
||||||
|
assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
||||||
|
assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() );
|
||||||
|
assertEquals( "Repository url does not match its name", "http://dist.codehaus.org",
|
||||||
|
repo.getUrl() );
|
||||||
|
assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
||||||
|
assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() );
|
||||||
|
assertEquals( "Repository url does not match its name", "http://private.example.com/internal",
|
||||||
|
repo.getUrl() );
|
||||||
|
assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
||||||
|
assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fail( "Unexpected order count" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//make sure to delete the test directory after tests
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
FileUtils.deleteDirectory( "target/remote-repo1" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -79,7 +79,7 @@ public class ProxyConfigurationTest
|
||||||
assertEquals( "repo2", repo.getId() );
|
assertEquals( "repo2", repo.getId() );
|
||||||
assertEquals( "http://www.ibiblio.org/maven", repo.getUrl() );
|
assertEquals( "http://www.ibiblio.org/maven", repo.getUrl() );
|
||||||
assertFalse( repo.isCacheFailures() );
|
assertFalse( repo.isCacheFailures() );
|
||||||
assertFalse( repo.isHardfail() );
|
assertTrue( repo.isHardfail() );
|
||||||
assertEquals( 3600, repo.getCachePeriod() );
|
assertEquals( 3600, repo.getCachePeriod() );
|
||||||
assertEquals( repo2, repo );
|
assertEquals( repo2, repo );
|
||||||
assertTrue( repo.isProxied() );
|
assertTrue( repo.isProxied() );
|
||||||
|
@ -108,72 +108,6 @@ public class ProxyConfigurationTest
|
||||||
assertEquals( repositories, config.getRepositories() );
|
assertEquals( repositories, config.getRepositories() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testLoadValidMavenProxyConfiguration()
|
|
||||||
// throws ValidationException, IOException
|
|
||||||
// {
|
|
||||||
// //must create the test directory bec configuration is using relative path which varies
|
|
||||||
// FileUtils.mkdir( "target/remote-repo1" );
|
|
||||||
//
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" );
|
|
||||||
//
|
|
||||||
// config.loadMavenProxyConfiguration( confFile );
|
|
||||||
//
|
|
||||||
// assertTrue( "cache path changed", config.getRepositoryCachePath().endsWith( "target" ) );
|
|
||||||
//
|
|
||||||
// assertEquals( "Count repositories", 4, config.getRepositories().size() );
|
|
||||||
//
|
|
||||||
// int idx = 0;
|
|
||||||
// for ( Iterator repos = config.getRepositories().iterator(); repos.hasNext(); )
|
|
||||||
// {
|
|
||||||
// idx++;
|
|
||||||
//
|
|
||||||
// ProxyRepository repo = (ProxyRepository) repos.next();
|
|
||||||
//
|
|
||||||
// //switch is made to check for ordering
|
|
||||||
// switch ( idx )
|
|
||||||
// {
|
|
||||||
// case 1:
|
|
||||||
// assertEquals( "Repository name not as expected", "local-repo", repo.getKey() );
|
|
||||||
// assertEquals( "Repository url does not match its name", "file:///./target/remote-repo1",
|
|
||||||
// repo.getUrl() );
|
|
||||||
// assertEquals( "Repository cache period check failed", 0, repo.getCachePeriod() );
|
|
||||||
// assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
|
|
||||||
// break;
|
|
||||||
// case 2:
|
|
||||||
// assertEquals( "Repository name not as expected", "www-ibiblio-org", repo.getKey() );
|
|
||||||
// assertEquals( "Repository url does not match its name", "http://www.ibiblio.org/maven2",
|
|
||||||
// repo.getUrl() );
|
|
||||||
// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
|
||||||
// assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
|
|
||||||
// break;
|
|
||||||
// case 3:
|
|
||||||
// assertEquals( "Repository name not as expected", "dist-codehaus-org", repo.getKey() );
|
|
||||||
// assertEquals( "Repository url does not match its name", "http://dist.codehaus.org",
|
|
||||||
// repo.getUrl() );
|
|
||||||
// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
|
||||||
// assertTrue( "Repository failure caching check failed", repo.isCacheFailures() );
|
|
||||||
// break;
|
|
||||||
// case 4:
|
|
||||||
// assertEquals( "Repository name not as expected", "private-example-com", repo.getKey() );
|
|
||||||
// assertEquals( "Repository url does not match its name", "http://private.example.com/internal",
|
|
||||||
// repo.getUrl() );
|
|
||||||
// assertEquals( "Repository cache period check failed", 3600, repo.getCachePeriod() );
|
|
||||||
// assertFalse( "Repository failure caching check failed", repo.isCacheFailures() );
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// fail( "Unexpected order count" );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //make sure to delete the test directory after tests
|
|
||||||
// finally
|
|
||||||
// {
|
|
||||||
// FileUtils.deleteDirectory( "target/remote-repo1" );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
protected void tearDown()
|
protected void tearDown()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue