Java源码示例:org.apache.maven.plugin.PluginResolutionException
示例1
@Override
public Artifact resolve(Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
WorkspaceReader wr = session.getWorkspaceReader();
NbWorkspaceReader nbwr = null;
if (wr instanceof NbWorkspaceReader) {
nbwr = (NbWorkspaceReader)wr;
//this only works reliably because the NbWorkspaceReader is part of the session, not a component
nbwr.silence();
}
try {
return super.resolve(plugin, repositories, session);
} finally {
if (nbwr != null) {
nbwr.normal();
}
}
}
示例2
@Override
public DependencyNode resolve(Plugin plugin, Artifact pluginArtifact, DependencyFilter dependencyFilter, List<RemoteRepository> repositories, RepositorySystemSession session) throws PluginResolutionException {
WorkspaceReader wr = session.getWorkspaceReader();
NbWorkspaceReader nbwr = null;
if (wr instanceof NbWorkspaceReader) {
nbwr = (NbWorkspaceReader)wr;
//this only works reliably because the NbWorkspaceReader is part of the session, not a component
nbwr.silence();
}
try {
return super.resolve(plugin, pluginArtifact, dependencyFilter, repositories, session);
} finally {
if (nbwr != null) {
nbwr.normal();
}
}
}
示例3
/**
* Taken from MojoExecutor of Don Brown. Make it working with Maven 3.1.
*
* @param plugin
* @param goal
* @param configuration
* @param env
* @throws MojoExecutionException
* @throws PluginResolutionException
* @throws PluginDescriptorParsingException
* @throws InvalidPluginDescriptorException
* @throws PluginManagerException
* @throws PluginConfigurationException
* @throws MojoFailureException
*/
private void executeMojo( Plugin plugin, String goal, Xpp3Dom configuration )
throws MojoExecutionException, PluginResolutionException, PluginDescriptorParsingException,
InvalidPluginDescriptorException, MojoFailureException, PluginConfigurationException, PluginManagerException
{
if ( configuration == null )
{
throw new NullPointerException( "configuration may not be null" );
}
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo( goal );
if ( mojoDescriptor == null )
{
throw new MojoExecutionException( "Could not find goal '" + goal + "' in plugin " + plugin.getGroupId()
+ ":" + plugin.getArtifactId() + ":" + plugin.getVersion() );
}
MojoExecution exec = mojoExecution( mojoDescriptor, configuration );
pluginManager.executeMojo( getMavenSession(), exec );
}
示例4
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");
Xpp3Dom config = getConfiguration(project, executionId);
Xpp3Dom processConfig = getProcessConfiguration(process);
Xpp3Dom globalConfig = getGlobalConfig();
Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);
PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
mavenSession.setCurrentProject(project);
this.pluginManager.executeMojo(mavenSession, mojoExecution);
List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process");
List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process");
if (procs == null) {
procs = new ArrayList<>();
getPluginContext().put("swarm-process", procs);
}
procs.addAll(launched);
mavenSession.setCurrentProject(this.project);
}
示例5
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
Plugin plugin = this.project.getPlugin(THORNTAIL_MAVEN_PLUGIN);
Xpp3Dom config = getConfiguration(project, executionId);
Xpp3Dom processConfig = getProcessConfiguration(process);
Xpp3Dom globalConfig = getGlobalConfig();
Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);
PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
mavenSession.setCurrentProject(project);
this.pluginManager.executeMojo(mavenSession, mojoExecution);
List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get(THORNTAIL_PROCESS);
List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get(THORNTAIL_PROCESS);
if (procs == null) {
procs = new ArrayList<>();
getPluginContext().put(THORNTAIL_PROCESS, procs);
}
procs.addAll(launched);
mavenSession.setCurrentProject(this.project);
}
示例6
@SuppressWarnings("unchecked")
protected void startProject(MavenProject project, String executionId, XmlPlexusConfiguration process) throws InvalidPluginDescriptorException, PluginResolutionException, PluginDescriptorParsingException, PluginNotFoundException, PluginConfigurationException, MojoFailureException, MojoExecutionException, PluginManagerException {
Plugin plugin = this.project.getPlugin("org.wildfly.swarm:wildfly-swarm-plugin");
Xpp3Dom config = getConfiguration(project, executionId);
Xpp3Dom processConfig = getProcessConfiguration(process);
Xpp3Dom globalConfig = getGlobalConfig();
Xpp3Dom mergedConfig = Xpp3DomUtils.mergeXpp3Dom(processConfig, config);
mergedConfig = Xpp3DomUtils.mergeXpp3Dom(mergedConfig, globalConfig);
PluginDescriptor pluginDescriptor = this.pluginManager.loadPlugin(plugin, project.getRemotePluginRepositories(), this.repositorySystemSession);
MojoDescriptor mojoDescriptor = pluginDescriptor.getMojo("start");
MojoExecution mojoExecution = new MojoExecution(mojoDescriptor, mergedConfig);
mavenSession.setCurrentProject(project);
this.pluginManager.executeMojo(mavenSession, mojoExecution);
List<SwarmProcess> launched = (List<SwarmProcess>) mavenSession.getPluginContext(pluginDescriptor, project).get("swarm-process");
List<SwarmProcess> procs = (List<SwarmProcess>) getPluginContext().get("swarm-process");
if (procs == null) {
procs = new ArrayList<>();
getPluginContext().put("swarm-process", procs);
}
procs.addAll(launched);
mavenSession.setCurrentProject(this.project);
}
示例7
@NbBundle.Messages({
"TXT_Artifact_Resolution_problem=Artifact Resolution problem",
"TXT_Artifact_Not_Found=Artifact Not Found",
"TXT_Cannot_Load_Project=Unable to properly load project",
"TXT_Cannot_read_model=Error reading project model",
"TXT_NoMsg=Exception thrown while loading maven project at {0}. See messages.log for more information."
})
private Collection<ProjectProblem> reportExceptions(MavenExecutionResult res) {
List<ProjectProblem> toRet = new ArrayList<ProjectProblem>();
for (Throwable e : res.getExceptions()) {
LOG.log(Level.FINE, "Error on loading project " + project.getProjectDirectory(), e);
if (e instanceof ArtifactResolutionException) { // XXX when does this occur?
toRet.add(ProjectProblem.createError(TXT_Artifact_Resolution_problem(), getDescriptionText(e)));
problemReporter.addMissingArtifact(((ArtifactResolutionException) e).getArtifact());
} else if (e instanceof ArtifactNotFoundException) { // XXX when does this occur?
toRet.add(ProjectProblem.createError(TXT_Artifact_Not_Found(), getDescriptionText(e)));
problemReporter.addMissingArtifact(((ArtifactNotFoundException) e).getArtifact());
} else if (e instanceof ProjectBuildingException) {
toRet.add(ProjectProblem.createError(TXT_Cannot_Load_Project(), getDescriptionText(e), new SanityBuildAction(project)));
if (e.getCause() instanceof ModelBuildingException) {
ModelBuildingException mbe = (ModelBuildingException) e.getCause();
for (ModelProblem mp : mbe.getProblems()) {
LOG.log(Level.FINE, mp.toString(), mp.getException());
if (mp.getException() instanceof UnresolvableModelException) {
// Probably obsoleted by ProblemReporterImpl.checkParent, but just in case:
UnresolvableModelException ume = (UnresolvableModelException) mp.getException();
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createProjectArtifact(ume.getGroupId(), ume.getArtifactId(), ume.getVersion()));
} else if (mp.getException() instanceof PluginResolutionException) {
Plugin plugin = ((PluginResolutionException) mp.getException()).getPlugin();
// XXX this is not actually accurate; should rather pick out the ArtifactResolutionException & ArtifactNotFoundException inside
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), "jar"));
} else if (mp.getException() instanceof PluginManagerException) {
PluginManagerException ex = (PluginManagerException) mp.getException();
problemReporter.addMissingArtifact(EmbedderFactory.getProjectEmbedder().createArtifact(ex.getPluginGroupId(), ex.getPluginArtifactId(), ex.getPluginVersion(), "jar"));
}
}
}
} else {
String msg = e.getMessage();
if(msg != null) {
LOG.log(Level.INFO, "Exception thrown while loading maven project at " + project.getProjectDirectory(), e); //NOI18N
toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), msg));
} else {
String path = project.getProjectDirectory().getPath();
toRet.add(ProjectProblem.createError(TXT_Cannot_read_model(), TXT_NoMsg(path)));
LOG.log(Level.WARNING, "Exception thrown while loading maven project at " + path, e); //NOI18N
}
}
}
return toRet;
}
示例8
private PluginDescriptor getPluginDescriptor( Plugin plugin )
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
{
return mavenPluginManagerHelper.getPluginDescriptor( plugin, getMavenProject().getRemotePluginRepositories(),
getMavenSession() );
}