use of com.github.sdedwards.m2e_nar.internal.model.NarExecution in project m2e-nar by maven-nar.
the class MavenUtils method readSettings.
public static <T extends AbstractCompileMojo> NarExecution readSettings(final ConfiguratorContext context, final IMavenProjectFacade facade, final MojoExecution compileExecution, final Class<T> mojoType, final String buildType, final IProgressMonitor monitor) throws CoreException {
final IMaven maven = context.getMaven();
final MavenProject mavenProject = facade.getMavenProject();
NarExecution settings = null;
if (compileExecution != null) {
// Load plugin with Maven in order to check config
// and to get at aol.properties resource inside the plugin
AbstractMojo narMojo = loadMojo(maven, mavenProject, compileExecution, AbstractMojo.class, monitor);
try {
// ClassRealm pluginRealm =
// compileExecution.getMojoDescriptor().getPluginDescriptor().getClassRealm();
// NarClassloader classloader = new NarClassloader(pluginRealm);
// INarExecutionBuilder builder =
// classloader.createNarExecutionBuilder(mavenProject,
// compileMojo);
// settings = builder.build(NarExecution.MAIN);
T compileMojo = getConfiguredMojo(maven, mavenProject, compileExecution, mojoType, narMojo.getLog(), monitor);
compileMojo.setNarProperties(new NarProperties(mavenProject, narMojo.getClass()));
// Need to call validate to set up defaults
compileMojo.validate();
// Resolve the NAR artifacts, possibly from workspace
compileMojo.prepareNarArtifacts(context, facade, monitor);
NarExecutionBuilder builder = new NarExecutionBuilder(compileMojo, compileExecution);
settings = builder.build(buildType);
} catch (MojoFailureException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't configure mojo"));
} catch (MojoExecutionException e) {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't configure mojo"));
} finally {
releaseMojo(maven, mavenProject, narMojo, compileExecution, monitor);
}
} else {
throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Couldn't find default-nar-compile execution"));
}
return settings;
}
use of com.github.sdedwards.m2e_nar.internal.model.NarExecution in project m2e-nar by maven-nar.
the class MavenUtils method buildTestCompileNarExecutions.
public static List<NarExecution> buildTestCompileNarExecutions(final ConfiguratorContext context, final IMavenProjectFacade facade, final IProgressMonitor monitor) throws CoreException {
List<NarExecution> narExecutions = new ArrayList<NarExecution>();
List<MojoExecution> testCompileExecutions = MavenUtils.getTestCompileExecutions(context, facade, monitor);
for (MojoExecution testCompileExecution : testCompileExecutions) {
NarExecution narSettings = MavenUtils.readTestCompileSettings(context, facade, testCompileExecution, monitor);
narExecutions.add(narSettings);
}
return narExecutions;
}
Aggregations