use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project intellij-community by JetBrains.
the class MavenEmbedder method buildSettings.
public static Settings buildSettings(PlexusContainer container, MavenEmbedderSettings embedderSettings) {
File file = embedderSettings.getGlobalSettingsFile();
if (file != null) {
System.setProperty(MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION, file.getPath());
}
Settings settings = null;
try {
MavenSettingsBuilder builder = (MavenSettingsBuilder) container.lookup(MavenSettingsBuilder.ROLE);
File userSettingsFile = embedderSettings.getUserSettingsFile();
if (userSettingsFile != null && userSettingsFile.exists() && !userSettingsFile.isDirectory()) {
settings = builder.buildSettings(userSettingsFile, false);
}
if (settings == null) {
settings = builder.buildSettings();
}
} catch (ComponentLookupException e) {
MavenEmbedderLog.LOG.error(e);
} catch (IOException e) {
MavenEmbedderLog.LOG.warn(e);
} catch (XmlPullParserException e) {
MavenEmbedderLog.LOG.warn(e);
}
if (settings == null) {
settings = new Settings();
}
if (embedderSettings.getLocalRepository() != null) {
settings.setLocalRepository(embedderSettings.getLocalRepository().getPath());
}
if (settings.getLocalRepository() == null) {
settings.setLocalRepository(System.getProperty("user.home") + "/.m2/repository");
}
settings.setOffline(embedderSettings.isWorkOffline());
settings.setInteractiveMode(false);
settings.setUsePluginRegistry(embedderSettings.isUsePluginRegistry());
RuntimeInfo runtimeInfo = new RuntimeInfo(settings);
runtimeInfo.setPluginUpdateOverride(embedderSettings.getPluginUpdatePolicy() == MavenEmbedderSettings.UpdatePolicy.ALWAYS_UPDATE);
settings.setRuntimeInfo(runtimeInfo);
return settings;
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project karaf by apache.
the class DependencyHelperFactory method createDependencyHelper.
/**
* <p>Create a new {@link DependencyHelper} based on what has been found in {@link org.codehaus.plexus.PlexusContainer}</p>
*
* <p>{@code karaf-maven-plugin} depends on {@code maven-core:3.0}, so for Maven 3.0.x, it may use this API directly.
* When using Maven 3.1.x/3.2.x, it should use reflection to invoke org.apache.maven.RepositoryUtils.toArtifact(Artifact)
* as this method directly references specific Aether implementation.</p>
*
* <p>When {@code karaf-maven-plugin} switches to {@code maven-core:3.1.0+}, reflection should be use for Sonatype variant of Aether.</p>
*
* @param container The Maven Plexus container to use.
* @param mavenProject The Maven project to use.
* @param mavenSession The Maven session.
* @param log The log to use for the messages.
* @return The {@link DependencyHelper} depending of the Maven version used.
* @throws MojoExecutionException If the plugin execution fails.
*/
public static DependencyHelper createDependencyHelper(PlexusContainer container, MavenProject mavenProject, MavenSession mavenSession, Log log) throws MojoExecutionException {
try {
if (container.hasComponent("org.sonatype.aether.RepositorySystem")) {
org.sonatype.aether.RepositorySystem system = container.lookup(org.sonatype.aether.RepositorySystem.class);
org.sonatype.aether.RepositorySystemSession session = mavenSession.getRepositorySession();
List<RemoteRepository> repositories = mavenProject.getRemoteProjectRepositories();
return new Dependency30Helper(repositories, session, system);
} else if (container.hasComponent("org.eclipse.aether.RepositorySystem")) {
org.eclipse.aether.RepositorySystem system = container.lookup(org.eclipse.aether.RepositorySystem.class);
Object session;
try {
session = MavenSession.class.getMethod("getRepositorySession").invoke(mavenSession);
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
List<?> repositories = mavenProject.getRemoteProjectRepositories();
return new Dependency31Helper(repositories, session, system);
}
} catch (ComponentLookupException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
throw new MojoExecutionException("Cannot locate either org.sonatype.aether.RepositorySystem or org.eclipse.aether.RepositorySystem");
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class AbstractSiteRenderingMojo method getReports.
protected List<MavenReportExecution> getReports() throws MojoExecutionException {
List<MavenReportExecution> allReports;
if (isMaven3OrMore()) {
// Maven 3
MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
mavenReportExecutorRequest.setLocalRepository(localRepository);
mavenReportExecutorRequest.setMavenSession(mavenSession);
mavenReportExecutorRequest.setProject(project);
mavenReportExecutorRequest.setReportPlugins(reportingPlugins);
MavenReportExecutor mavenReportExecutor;
try {
mavenReportExecutor = (MavenReportExecutor) container.lookup(MavenReportExecutor.class.getName());
} catch (ComponentLookupException e) {
throw new MojoExecutionException("could not get MavenReportExecutor component", e);
}
allReports = mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
} else {
// Maven 2
allReports = new ArrayList<MavenReportExecution>(reports.size());
for (MavenReport report : reports) {
allReports.add(new MavenReportExecution(report));
}
}
// filter out reports that can't be generated
List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(allReports.size());
for (MavenReportExecution exec : allReports) {
if (exec.canGenerateReport()) {
reportExecutions.add(exec);
}
}
return reportExecutions;
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class DefaultAssemblyArchiver method configureArchiver.
private void configureArchiver(final Archiver archiver, final AssemblerConfigurationSource configSource) {
Xpp3Dom config;
try {
config = Xpp3DomBuilder.build(new StringReader(configSource.getArchiverConfig()));
} catch (final XmlPullParserException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
} catch (final IOException e) {
throw new ArchiverException("Failed to parse archiver configuration for: " + archiver.getClass().getName(), e);
}
getLogger().debug("Configuring archiver: '" + archiver.getClass().getName() + "' -->");
try {
configureComponent(archiver, config, configSource);
} catch (final ComponentConfigurationException e) {
throw new ArchiverException("Failed to configure archiver: " + archiver.getClass().getName(), e);
} catch (final ComponentLookupException e) {
throw new ArchiverException("Failed to lookup configurator for setup of archiver: " + archiver.getClass().getName(), e);
}
getLogger().debug("-- end configuration --");
}
use of org.codehaus.plexus.component.repository.exception.ComponentLookupException in project maven-plugins by apache.
the class PdfMojo method getReports.
protected List<MavenReportExecution> getReports() throws MojoExecutionException {
if (isMaven3OrMore()) {
MavenReportExecutorRequest mavenReportExecutorRequest = new MavenReportExecutorRequest();
mavenReportExecutorRequest.setLocalRepository(localRepository);
mavenReportExecutorRequest.setMavenSession(session);
mavenReportExecutorRequest.setProject(project);
mavenReportExecutorRequest.setReportPlugins(reportPlugins);
MavenReportExecutor mavenReportExecutor;
try {
mavenReportExecutor = (MavenReportExecutor) container.lookup(MavenReportExecutor.class.getName());
} catch (ComponentLookupException e) {
throw new MojoExecutionException("could not get MavenReportExecutor component", e);
}
return mavenReportExecutor.buildMavenReports(mavenReportExecutorRequest);
}
List<MavenReportExecution> reportExecutions = new ArrayList<MavenReportExecution>(reports.length);
for (MavenReport report : reports) {
if (report.canGenerateReport()) {
reportExecutions.add(new MavenReportExecution(report));
}
}
return reportExecutions;
}
Aggregations