use of org.codehaus.plexus.PlexusContainer in project maven-plugins by apache.
the class AbstractAnalyzeMojo method createProjectDependencyAnalyzer.
protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException {
final String role = ProjectDependencyAnalyzer.ROLE;
final String roleHint = analyzer;
try {
final PlexusContainer container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
return (ProjectDependencyAnalyzer) container.lookup(role, roleHint);
} catch (Exception exception) {
throw new MojoExecutionException("Failed to instantiate ProjectDependencyAnalyser with role " + role + " / role-hint " + roleHint, exception);
}
}
use of org.codehaus.plexus.PlexusContainer in project kie-wb-common by kiegroup.
the class AFMavenCli method doMain.
public int doMain(AFCliRequest cliRequest, ClassWorld classWorld) {
PlexusContainer localContainer = null;
PrintStream originalOut = System.out;
PrintStream originalErr = System.err;
try {
initialize(cliRequest);
cli(cliRequest);
logging(cliRequest);
version(cliRequest);
properties(cliRequest);
localContainer = container(cliRequest, classWorld);
commands(cliRequest);
configure(cliRequest);
toolchains(cliRequest);
populateRequest(cliRequest);
repository(cliRequest);
return execute(cliRequest);
} catch (ExitException e) {
e.getStackTrace();
return e.exitCode;
} catch (UnrecognizedOptionException e) {
e.getStackTrace();
return 1;
} catch (BuildAbort e) {
e.getStackTrace();
AFCLIReportingUtils.showError(slf4jLogger, "ABORTED", e, cliRequest.isShowErrors());
return 2;
} catch (Exception e) {
e.getStackTrace();
AFCLIReportingUtils.showError(slf4jLogger, "Error executing Maven.", e, cliRequest.isShowErrors());
return 1;
} finally {
System.setOut(originalOut);
System.setErr(originalErr);
if (localContainer != null) {
localContainer.dispose();
localContainer = null;
}
}
}
use of org.codehaus.plexus.PlexusContainer in project intellij-community by JetBrains.
the class Maven2ServerEmbedderImpl method create.
public static Maven2ServerEmbedderImpl create(MavenServerSettings facadeSettings) throws RemoteException {
MavenEmbedderSettings settings = new MavenEmbedderSettings();
List<String> commandLineOptions = new ArrayList<String>();
String mavenEmbedderCliOptions = System.getProperty(MavenServerEmbedder.MAVEN_EMBEDDER_CLI_ADDITIONAL_ARGS);
if (mavenEmbedderCliOptions != null) {
commandLineOptions.addAll(StringUtil.splitHonorQuotes(mavenEmbedderCliOptions, ' '));
}
settings.setConfigurator(new PlexusComponentConfigurator() {
public void configureComponents(@NotNull PlexusContainer c) {
setupContainer(c);
}
});
Maven2ServerConsoleWrapper consoleWrapper = new Maven2ServerConsoleWrapper();
consoleWrapper.setThreshold(facadeSettings.getLoggingLevel());
settings.setLogger(consoleWrapper);
settings.setRecursive(false);
settings.setWorkOffline(facadeSettings.isOffline());
settings.setUsePluginRegistry(false);
settings.setMavenHome(facadeSettings.getMavenHome());
settings.setUserSettingsFile(facadeSettings.getUserSettingsFile());
settings.setGlobalSettingsFile(facadeSettings.getGlobalSettingsFile());
settings.setLocalRepository(facadeSettings.getLocalRepository());
if (commandLineOptions.contains("-U") || commandLineOptions.contains("--update-snapshots")) {
settings.setSnapshotUpdatePolicy(MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE);
} else {
settings.setSnapshotUpdatePolicy(convertUpdatePolicy(facadeSettings.getSnapshotUpdatePolicy()));
}
settings.setPluginUpdatePolicy(convertUpdatePolicy(facadeSettings.getPluginUpdatePolicy()));
settings.setProperties(MavenServerUtil.collectSystemProperties());
return new Maven2ServerEmbedderImpl(MavenEmbedder.create(settings), consoleWrapper);
}
use of org.codehaus.plexus.PlexusContainer in project maven-dependency-plugin by apache.
the class AbstractAnalyzeMojo method createProjectDependencyAnalyzer.
/**
* @return {@link ProjectDependencyAnalyzer}
* @throws MojoExecutionException in case of an error.
*/
protected ProjectDependencyAnalyzer createProjectDependencyAnalyzer() throws MojoExecutionException {
final String role = ProjectDependencyAnalyzer.ROLE;
final String roleHint = analyzer;
try {
final PlexusContainer container = (PlexusContainer) context.get(PlexusConstants.PLEXUS_KEY);
return (ProjectDependencyAnalyzer) container.lookup(role, roleHint);
} catch (Exception exception) {
throw new MojoExecutionException("Failed to instantiate ProjectDependencyAnalyser with role " + role + " / role-hint " + roleHint, exception);
}
}
use of org.codehaus.plexus.PlexusContainer in project pom-manipulation-ext by release-engineering.
the class Cli method parseSettings.
private Settings parseSettings(File settings) throws PlexusContainerException, ComponentLookupException, SettingsBuildingException {
PlexusContainer container = new DefaultPlexusContainer();
DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
settingsRequest.setUserSettingsFile(settings);
settingsRequest.setGlobalSettingsFile(DEFAULT_GLOBAL_SETTINGS_FILE);
settingsRequest.setUserProperties(session.getUserProperties());
settingsRequest.setSystemProperties(System.getProperties());
SettingsBuilder settingsBuilder = container.lookup(SettingsBuilder.class);
SettingsBuildingResult settingsResult = settingsBuilder.build(settingsRequest);
Settings effectiveSettings = settingsResult.getEffectiveSettings();
ProfileSelector profileSelector = container.lookup(ProfileSelector.class);
ProfileActivationContext profileActivationContext = new DefaultProfileActivationContext().setActiveProfileIds(effectiveSettings.getActiveProfiles());
List<org.apache.maven.model.Profile> modelProfiles = new ArrayList<>();
for (Profile profile : effectiveSettings.getProfiles()) {
modelProfiles.add(SettingsUtils.convertFromSettingsProfile(profile));
}
List<org.apache.maven.model.Profile> activeModelProfiles = profileSelector.getActiveProfiles(modelProfiles, profileActivationContext, new ModelProblemCollector() {
@Override
public void add(ModelProblem.Severity severity, String message, InputLocation location, Exception cause) {
// do nothing
}
});
List<String> activeProfiles = new ArrayList<>();
for (org.apache.maven.model.Profile profile : activeModelProfiles) {
activeProfiles.add(profile.getId());
}
effectiveSettings.setActiveProfiles(activeProfiles);
return effectiveSettings;
}
Aggregations