mirror of https://github.com/apache/maven.git
[MNG-6680] Convert Maven Settings Builder to JSR 330
Use @Named and @Singleton throughout, and switch to constructor injection for DefaultSettingsBuilder. This closes #246
This commit is contained in:
parent
c2f13f7e87
commit
c5ede2fef8
|
@ -46,8 +46,8 @@ under the License.
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
|
@ -55,7 +55,7 @@ under the License.
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-annotations</artifactId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
|
@ -70,8 +70,8 @@ under the License.
|
|||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
<groupId>org.eclipse.sisu</groupId>
|
||||
<artifactId>sisu-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -27,6 +27,10 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.building.FileSource;
|
||||
import org.apache.maven.building.Source;
|
||||
import org.apache.maven.settings.Settings;
|
||||
|
@ -36,8 +40,6 @@ import org.apache.maven.settings.io.SettingsReader;
|
|||
import org.apache.maven.settings.io.SettingsWriter;
|
||||
import org.apache.maven.settings.merge.MavenSettingsMerger;
|
||||
import org.apache.maven.settings.validation.SettingsValidator;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.interpolation.EnvarBasedValueSource;
|
||||
import org.codehaus.plexus.interpolation.InterpolationException;
|
||||
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
|
||||
|
@ -49,21 +51,29 @@ import org.codehaus.plexus.interpolation.RegexBasedInterpolator;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = SettingsBuilder.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultSettingsBuilder
|
||||
implements SettingsBuilder
|
||||
{
|
||||
|
||||
@Requirement
|
||||
private SettingsReader settingsReader;
|
||||
|
||||
@Requirement
|
||||
private SettingsWriter settingsWriter;
|
||||
|
||||
@Requirement
|
||||
private SettingsValidator settingsValidator;
|
||||
|
||||
private MavenSettingsMerger settingsMerger = new MavenSettingsMerger();
|
||||
private final MavenSettingsMerger settingsMerger = new MavenSettingsMerger();
|
||||
|
||||
@Inject
|
||||
public DefaultSettingsBuilder( SettingsReader settingsReader,
|
||||
SettingsWriter settingsWriter,
|
||||
SettingsValidator settingsValidator )
|
||||
{
|
||||
this.settingsReader = settingsReader;
|
||||
this.settingsWriter = settingsWriter;
|
||||
this.settingsValidator = settingsValidator;
|
||||
}
|
||||
|
||||
public DefaultSettingsBuilder setSettingsReader( SettingsReader settingsReader )
|
||||
{
|
||||
|
|
|
@ -59,13 +59,9 @@ public class DefaultSettingsBuilderFactory
|
|||
*/
|
||||
public DefaultSettingsBuilder newInstance()
|
||||
{
|
||||
DefaultSettingsBuilder builder = new DefaultSettingsBuilder();
|
||||
|
||||
builder.setSettingsReader( newSettingsReader() );
|
||||
builder.setSettingsWriter( newSettingsWriter() );
|
||||
builder.setSettingsValidator( newSettingsValidator() );
|
||||
|
||||
return builder;
|
||||
return new DefaultSettingsBuilder( newSettingsReader(),
|
||||
newSettingsWriter(),
|
||||
newSettingsValidator() );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,13 +22,15 @@ package org.apache.maven.settings.crypto;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.settings.Proxy;
|
||||
import org.apache.maven.settings.Server;
|
||||
import org.apache.maven.settings.building.DefaultSettingsProblem;
|
||||
import org.apache.maven.settings.building.SettingsProblem;
|
||||
import org.apache.maven.settings.building.SettingsProblem.Severity;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
|
||||
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
|
||||
|
||||
|
@ -37,13 +39,18 @@ import org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = SettingsDecrypter.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultSettingsDecrypter
|
||||
implements SettingsDecrypter
|
||||
{
|
||||
private final SecDispatcher securityDispatcher;
|
||||
|
||||
@Requirement( hint = "maven" )
|
||||
private SecDispatcher securityDispatcher;
|
||||
@Inject
|
||||
public DefaultSettingsDecrypter( @Named( "maven" ) SecDispatcher securityDispatcher )
|
||||
{
|
||||
this.securityDispatcher = securityDispatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SettingsDecryptionResult decrypt( SettingsDecryptionRequest request )
|
||||
|
|
|
@ -26,9 +26,11 @@ import java.io.Reader;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.util.ReaderFactory;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
|
@ -37,7 +39,8 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = SettingsReader.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultSettingsReader
|
||||
implements SettingsReader
|
||||
{
|
||||
|
|
|
@ -27,9 +27,11 @@ import java.io.Writer;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Writer;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.util.WriterFactory;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +39,8 @@ import org.codehaus.plexus.util.WriterFactory;
|
|||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
@Component( role = SettingsWriter.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultSettingsWriter
|
||||
implements SettingsWriter
|
||||
{
|
||||
|
|
|
@ -23,6 +23,9 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.apache.maven.settings.Mirror;
|
||||
import org.apache.maven.settings.Profile;
|
||||
import org.apache.maven.settings.Repository;
|
||||
|
@ -31,13 +34,13 @@ import org.apache.maven.settings.Server;
|
|||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.building.SettingsProblem.Severity;
|
||||
import org.apache.maven.settings.building.SettingsProblemCollector;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author Milos Kleint
|
||||
*/
|
||||
@Component( role = SettingsValidator.class )
|
||||
@Named
|
||||
@Singleton
|
||||
public class DefaultSettingsValidator
|
||||
implements SettingsValidator
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue