本文整理汇总了Java中org.apache.maven.settings.building.SettingsBuildingResult类的典型用法代码示例。如果您正苦于以下问题:Java SettingsBuildingResult类的具体用法?Java SettingsBuildingResult怎么用?Java SettingsBuildingResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SettingsBuildingResult类属于org.apache.maven.settings.building包,在下文中一共展示了SettingsBuildingResult类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadMavenSettings
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
public static Settings loadMavenSettings()
throws SettingsBuildingException {
// http://stackoverflow.com/questions/27818659/loading-mavens-settings-xml-for-jcabi-aether-to-use
SettingsBuildingRequest settingsBuildingRequest =
new DefaultSettingsBuildingRequest();
settingsBuildingRequest.setSystemProperties(System.getProperties());
settingsBuildingRequest.setUserSettingsFile(new File(settingsXml));
settingsBuildingRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
SettingsBuildingResult settingsBuildingResult;
DefaultSettingsBuilderFactory mvnSettingBuilderFactory =
new DefaultSettingsBuilderFactory();
DefaultSettingsBuilder settingsBuilder =
mvnSettingBuilderFactory.newInstance();
settingsBuildingResult = settingsBuilder.build(settingsBuildingRequest);
Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings();
return effectiveSettings;
}
示例2: onEvent
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
@Override
public void onEvent(Object event) throws Exception {
if (event instanceof SettingsBuildingResult) {
logger.debug("[LocalRepositoryDirectorySpy]: Received a " + SettingsBuildingResult.class.getSimpleName());
String localRepositoryPath = ((SettingsBuildingResult) event).getEffectiveSettings().getLocalRepository();
if (localRepositoryPath == null) {
logger.debug("[LocalRepositoryDirectorySpy]: No local repository folder configured in effective settings");
localRepositoryPath = RepositorySystem.defaultUserLocalRepository.getAbsolutePath();
}
File localRepositoryFile = new File(localRepositoryPath);
if (localRepositoryFile.exists() && localRepositoryFile.isDirectory()) {
this.localRepositoryDirectory = localRepositoryFile;
logger.info("[LocalRepositoryDirectorySpy]: LocalRepositoryDirectory is initialized to " + localRepositoryFile.getAbsolutePath());
} else {
if (stamper.isEnabled()) {
throw new FreezeException("[LocalRepositoryDirectorySpy]: Invalid local repository folder " +
localRepositoryPath +
"in effective settings");
}
}
}
}
示例3: invokers
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
/**
* Apply maven invoker settings.
* @param builder Settings builder.
* @param result User and global settings.
* @return User, global and invoker settings.
*/
private Settings invokers(final SettingsBuilder builder,
final SettingsBuildingResult result) {
Settings main = result.getEffectiveSettings();
final File[] files = new File(System.getProperty("user.dir"))
.getParentFile().listFiles(
(FileFilter) new NameFileFilter("interpolated-settings.xml")
);
if (files.length == 1) {
final DefaultSettingsBuildingRequest irequest =
new DefaultSettingsBuildingRequest();
irequest.setUserSettingsFile(files[0]);
try {
final Settings isettings = builder.build(irequest)
.getEffectiveSettings();
SettingsUtils.merge(isettings, main, TrackableBase.USER_LEVEL);
main = isettings;
} catch (final SettingsBuildingException ex) {
throw new IllegalStateException(ex);
}
}
return main;
}
示例4: settings
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
/**
* Provide settings from maven.
* @return Maven settings.
*/
private Settings settings() {
final SettingsBuilder builder =
new DefaultSettingsBuilderFactory().newInstance();
final SettingsBuildingRequest request =
new DefaultSettingsBuildingRequest();
final String user =
System.getProperty("org.apache.maven.user-settings");
if (user == null) {
request.setUserSettingsFile(
new File(
new File(
System.getProperty("user.home")
).getAbsoluteFile(),
"/.m2/settings.xml"
)
);
} else {
request.setUserSettingsFile(new File(user));
}
final String global =
System.getProperty("org.apache.maven.global-settings");
if (global != null) {
request.setGlobalSettingsFile(new File(global));
}
final SettingsBuildingResult result;
try {
result = builder.build(request);
} catch (final SettingsBuildingException ex) {
throw new IllegalStateException(ex);
}
return this.invokers(builder, result);
}
示例5: getSettings
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
public Settings getSettings()
{
try
{
SettingsBuilder settingsBuilder = new DefaultSettingsBuilderFactory().newInstance();
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
String userSettingsLocation = System.getProperty(ALT_USER_SETTINGS_XML_LOCATION);
// TeamCity sets the settings.xml in a different system property
String teamCitySettingsLocation = System.getProperty("teamcity.maven.userSettings.path");
if (userSettingsLocation != null)
{
settingsRequest.setUserSettingsFile(new File(userSettingsLocation));
}
else if (teamCitySettingsLocation != null)
{
settingsRequest.setUserSettingsFile(new File(teamCitySettingsLocation));
}
else
{
settingsRequest.setUserSettingsFile(new File(getUserHomeDir(), "/.m2/settings.xml"));
}
String globalSettingsLocation = System.getProperty(ALT_GLOBAL_SETTINGS_XML_LOCATION);
if (globalSettingsLocation != null)
{
settingsRequest.setGlobalSettingsFile(new File(globalSettingsLocation));
}
else
{
if (M2_HOME != null)
{
settingsRequest.setGlobalSettingsFile(new File(M2_HOME, "/conf/settings.xml"));
}
}
SettingsBuildingResult settingsBuildingResult = settingsBuilder.build(settingsRequest);
Settings effectiveSettings = settingsBuildingResult.getEffectiveSettings();
if (effectiveSettings.getLocalRepository() == null)
{
String userRepositoryLocation = System.getProperty(ALT_LOCAL_REPOSITORY_LOCATION);
if (userRepositoryLocation != null)
{
effectiveSettings.setLocalRepository(userRepositoryLocation);
}
else
{
effectiveSettings.setLocalRepository(getUserHomePath() + "/.m2/repository");
}
}
return effectiveSettings;
}
catch (SettingsBuildingException e)
{
throw new RuntimeException(e);
}
}
示例6: settings
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
private void settings( CliRequest cliRequest )
throws Exception
{
File userSettingsFile;
if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) )
{
userSettingsFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) );
userSettingsFile = resolveFile( userSettingsFile, cliRequest.workingDirectory );
if ( !userSettingsFile.isFile() )
{
throw new FileNotFoundException( "The specified user settings file does not exist: "
+ userSettingsFile );
}
}
else
{
userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
}
File globalSettingsFile;
if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) )
{
globalSettingsFile =
new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) );
globalSettingsFile = resolveFile( globalSettingsFile, cliRequest.workingDirectory );
if ( !globalSettingsFile.isFile() )
{
throw new FileNotFoundException( "The specified global settings file does not exist: "
+ globalSettingsFile );
}
}
else
{
globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
}
cliRequest.request.setGlobalSettingsFile( globalSettingsFile );
cliRequest.request.setUserSettingsFile( userSettingsFile );
SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile( globalSettingsFile );
settingsRequest.setUserSettingsFile( userSettingsFile );
settingsRequest.setSystemProperties( cliRequest.systemProperties );
settingsRequest.setUserProperties( cliRequest.userProperties );
eventSpyDispatcher.onEvent( settingsRequest );
slf4jLogger.debug( "Reading global settings from "
+ getSettingsLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) );
slf4jLogger.debug( "Reading user settings from "
+ getSettingsLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) );
SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest );
eventSpyDispatcher.onEvent( settingsResult );
executionRequestPopulator.populateFromSettings( cliRequest.request, settingsResult.getEffectiveSettings() );
if ( !settingsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() )
{
slf4jLogger.warn( "" );
slf4jLogger.warn( "Some problems were encountered while building the effective settings" );
for ( SettingsProblem problem : settingsResult.getProblems() )
{
slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() );
}
slf4jLogger.warn( "" );
}
}
示例7: process
import org.apache.maven.settings.building.SettingsBuildingResult; //导入依赖的package包/类
@Override
public void process(AFCliRequest cliRequest)
throws Exception {
CommandLine commandLine = cliRequest.getCommandLine();
String workingDirectory = cliRequest.getWorkingDirectory();
MavenExecutionRequest request = cliRequest.getRequest();
Path userSettingsFile;
if (commandLine.hasOption(CLIManager.ALTERNATE_USER_SETTINGS)) {
userSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_USER_SETTINGS));
userSettingsFile = resolvePath(userSettingsFile,
workingDirectory);
if (!Files.isRegularFile(userSettingsFile)) {
throw new FileNotFoundException("The specified user settings file does not exist: "
+ userSettingsFile);
}
} else {
userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
}
Path globalSettingsFile;
if (commandLine.hasOption(CLIManager.ALTERNATE_GLOBAL_SETTINGS)) {
globalSettingsFile = Paths.get(commandLine.getOptionValue(CLIManager.ALTERNATE_GLOBAL_SETTINGS));
globalSettingsFile = resolvePath(globalSettingsFile,
workingDirectory);
if (!Files.isRegularFile(globalSettingsFile)) {
throw new FileNotFoundException("The specified global settings file does not exist: "
+ globalSettingsFile);
}
} else {
globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
}
request.setGlobalSettingsFile(globalSettingsFile.toFile());
request.setUserSettingsFile(userSettingsFile.toFile());
AFSettingsBuildingRequest settingsRequest = new AFSettingsBuildingRequest();
settingsRequest.setGlobalSettingsFile(globalSettingsFile.toFile());
settingsRequest.setUserSettingsFile(userSettingsFile.toFile());
settingsRequest.setSystemProperties(cliRequest.getSystemProperties());
settingsRequest.setUserProperties(cliRequest.getUserProperties());
if (request.getEventSpyDispatcher() != null) {
request.getEventSpyDispatcher().onEvent(settingsRequest);
}
logger.debug("Reading global settings from "
+ getLocation(settingsRequest.getGlobalSettingsSource(),
settingsRequest.getGlobalSettingsPath()));
logger.debug("Reading user settings from "
+ getLocation(settingsRequest.getUserSettingsSource(),
settingsRequest.getUserSettingsPath()));
SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);
if (request.getEventSpyDispatcher() != null) {
request.getEventSpyDispatcher().onEvent(settingsResult);
}
populateFromSettings(request,
settingsResult.getEffectiveSettings());
if (!settingsResult.getProblems().isEmpty() && logger.isWarnEnabled()) {
logger.warn("");
logger.warn("Some problems were encountered while building the effective settings");
for (SettingsProblem problem : settingsResult.getProblems()) {
logger.warn(problem.getMessage() + " @ " + problem.getLocation());
}
logger.warn("");
}
}