EA-49679 - NSE: Thread.run

This commit is contained in:
Sergey Evdokimov
2013-11-18 17:16:48 +04:00
parent 2bcf8e5e41
commit 0895ae052b
6 changed files with 34 additions and 25 deletions
@@ -36,7 +36,7 @@ public interface MavenServerEmbedder extends Remote {
@NotNull Collection<String> activeProfiles) throws RemoteException,
MavenServerProcessCanceledException;
@NotNull
@Nullable
String evaluateEffectivePom(@NotNull File file, @NotNull List<String> activeProfiles) throws RemoteException,
MavenServerProcessCanceledException;
@@ -198,7 +198,7 @@ public class Maven2ServerEmbedderImpl extends MavenRemoteObject implements Maven
return result;
}
@NotNull
@Nullable
public String evaluateEffectivePom(@NotNull File file, @NotNull List<String> activeProfiles) {
throw new UnsupportedOperationException();
}
@@ -287,7 +287,7 @@ public class Maven3ServerEmbedderImpl extends MavenRemoteObject implements Maven
return createExecutionResult(file, result, listener.getRootNode());
}
@NotNull
@Nullable
@Override
public String evaluateEffectivePom(@NotNull File file, @NotNull List<String> activeProfiles)
throws RemoteException, MavenServerProcessCanceledException {
@@ -17,6 +17,7 @@ import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.io.IOException;
@@ -43,38 +44,43 @@ public class MavenEffectivePomDumper {
private static final String SETTINGS_XSD_URL = "http://maven.apache.org/xsd/settings-1.0.0.xsd";
// See org.apache.maven.plugins.help.EffectivePomMojo#execute from maven-help-plugin
@Nullable
public static String evaluateEffectivePom(final Maven3ServerEmbedderImpl embedder,
@NotNull final File file,
@NotNull List<String> activeProfiles)
throws RemoteException, MavenServerProcessCanceledException {
final MavenExecutionRequest
request = embedder.createRequest(file, activeProfiles, Collections.<String>emptyList(), Collections.<String>emptyList());
final StringWriter w = new StringWriter();
embedder.executeWithMavenSession(request, new Runnable() {
@Override
public void run() {
try {
// copied from DefaultMavenProjectBuilder.buildWithDependencies
ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class);
ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest());
try {
final MavenExecutionRequest
request = embedder.createRequest(file, activeProfiles, Collections.<String>emptyList(), Collections.<String>emptyList());
MavenProject project = buildingResult.getProject();
embedder.executeWithMavenSession(request, new Runnable() {
@Override
public void run() {
try {
// copied from DefaultMavenProjectBuilder.buildWithDependencies
ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class);
ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest());
XMLWriter writer = new PrettyPrintXMLWriter(w, StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE));
MavenProject project = buildingResult.getProject();
writeHeader(writer);
XMLWriter writer = new PrettyPrintXMLWriter(w, StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE));
writeEffectivePom(project, writer);
writeHeader(writer);
writeEffectivePom(project, writer);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
});
}
catch (Exception e) {
return null;
}
return w.toString();
}
@@ -66,7 +66,10 @@ public class MavenShowEffectivePom extends AnAction implements DumbAware {
if (project.isDisposed()) return;
if (s == null) { // null means UnsupportedOperationException
showUnsupportedNotification(project, file);
new Notification(MavenUtil.MAVEN_NOTIFICATION_GROUP,
"Error",
"Failed to evaluate effective pom.",
NotificationType.ERROR).notify(project);
return;
}
@@ -101,7 +101,7 @@ public abstract class MavenEmbedderWrapper extends RemoteObjectWrapper<MavenServ
});
}
@NotNull
@Nullable
public String evaluateEffectivePom(@NotNull final VirtualFile file, @NotNull final Collection<String> activeProfiles)
throws MavenProcessCanceledException {
return perform(new RetriableCancelable<String>() {