use of org.apache.maven.plugin.MojoExecutionException in project jetty.project by eclipse.
the class JspcMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (getLog().isDebugEnabled()) {
getLog().info("webAppSourceDirectory=" + webAppSourceDirectory);
getLog().info("generatedClasses=" + generatedClasses);
getLog().info("webXmlFragment=" + webXmlFragment);
getLog().info("webXml=" + webXml);
getLog().info("insertionMarker=" + (insertionMarker == null || insertionMarker.equals("") ? END_OF_WEBAPP : insertionMarker));
getLog().info("keepSources=" + keepSources);
getLog().info("mergeFragment=" + mergeFragment);
if (sourceVersion != null)
getLog().info("sourceVersion=" + sourceVersion);
if (targetVersion != null)
getLog().info("targetVersion=" + targetVersion);
}
try {
prepare();
compile();
cleanupSrcs();
mergeWebXml();
} catch (Exception e) {
throw new MojoExecutionException("Failure processing jsps", e);
}
}
use of org.apache.maven.plugin.MojoExecutionException in project jetty.project by eclipse.
the class JettyRunMojo method checkPomConfiguration.
/**
* Verify the configuration given in the pom.
*
* @see AbstractJettyMojo#checkPomConfiguration()
*/
public void checkPomConfiguration() throws MojoExecutionException {
// check the location of the static content/jsps etc
try {
if ((webAppSourceDirectory == null) || !webAppSourceDirectory.exists()) {
getLog().info("webAppSourceDirectory" + (webAppSourceDirectory == null ? " not set." : (webAppSourceDirectory.getAbsolutePath() + " does not exist.")) + " Trying " + DEFAULT_WEBAPP_SRC);
webAppSourceDirectory = new File(project.getBasedir(), DEFAULT_WEBAPP_SRC);
if (!webAppSourceDirectory.exists()) {
getLog().info("webAppSourceDirectory " + webAppSourceDirectory.getAbsolutePath() + " does not exist. Trying " + project.getBuild().getDirectory() + File.separator + FAKE_WEBAPP);
//try last resort of making a fake empty dir
File target = new File(project.getBuild().getDirectory());
webAppSourceDirectory = new File(target, FAKE_WEBAPP);
if (!webAppSourceDirectory.exists())
webAppSourceDirectory.mkdirs();
}
} else
getLog().info("Webapp source directory = " + webAppSourceDirectory.getCanonicalPath());
} catch (IOException e) {
throw new MojoExecutionException("Webapp source directory does not exist", e);
}
// check reload mechanic
if (!"automatic".equalsIgnoreCase(reload) && !"manual".equalsIgnoreCase(reload)) {
throw new MojoExecutionException("invalid reload mechanic specified, must be 'automatic' or 'manual'");
} else {
getLog().info("Reload Mechanic: " + reload);
}
// check the classes to form a classpath with
try {
//allow a webapp with no classes in it (just jsps/html)
if (classesDirectory != null) {
if (!classesDirectory.exists())
getLog().info("Classes directory " + classesDirectory.getCanonicalPath() + " does not exist");
else
getLog().info("Classes = " + classesDirectory.getCanonicalPath());
} else
getLog().info("Classes directory not set");
} catch (IOException e) {
throw new MojoExecutionException("Location of classesDirectory does not exist");
}
}
use of org.apache.maven.plugin.MojoExecutionException in project jetty.project by eclipse.
the class JettyRunWarExplodedMojo method configureScanner.
/**
* @see AbstractJettyMojo#configureScanner()
*/
public void configureScanner() throws MojoExecutionException {
scanner.watch(project.getFile().toPath());
File webInfDir = new File(war, "WEB-INF");
File webXml = new File(webInfDir, "web.xml");
if (webXml.exists())
scanner.watch(webXml.toPath());
File jettyWebXmlFile = findJettyWebXmlFile(webInfDir);
if (jettyWebXmlFile != null)
scanner.watch(jettyWebXmlFile.toPath());
File jettyEnvXmlFile = new File(webInfDir, "jetty-env.xml");
if (jettyEnvXmlFile.exists())
scanner.watch(jettyEnvXmlFile.toPath());
File classes = new File(webInfDir, "classes");
if (classes.exists()) {
PathWatcher.Config classesConfig = new PathWatcher.Config(classes.toPath());
classesConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH);
scanner.watch(classesConfig);
}
File lib = new File(webInfDir, "lib");
if (lib.exists()) {
PathWatcher.Config libConfig = new PathWatcher.Config(lib.toPath());
libConfig.setRecurseDepth(PathWatcher.Config.UNLIMITED_DEPTH);
scanner.watch(libConfig);
}
scanner.addListener(new PathWatcher.EventListListener() {
@Override
public void onPathWatchEvents(List<PathWatchEvent> events) {
try {
boolean reconfigure = false;
for (PathWatchEvent e : events) {
if (e.getPath().equals(project.getFile().toPath())) {
reconfigure = true;
break;
}
}
restartWebApp(reconfigure);
} catch (Exception e) {
getLog().error("Error reconfiguring/restarting webapp after change in watched files", e);
}
}
});
}
use of org.apache.maven.plugin.MojoExecutionException in project che by eclipse.
the class TypeScriptDTOGeneratorMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Generating TypeScript DTO");
TypeScriptDtoGenerator typeScriptDtoGenerator = new TypeScriptDtoGenerator();
typeScriptDtoGenerator.setUseClassPath(useClassPath);
// define output path for the file to write with typescript definition
String output = typeScriptDtoGenerator.execute();
this.typescriptFile = new File(targetDirectory, project.getArtifactId() + ".ts");
File parentDir = this.typescriptFile.getParentFile();
if (!parentDir.exists() && !parentDir.mkdirs()) {
throw new MojoExecutionException("Unable to create a directory for writing DTO typescript file '" + parentDir + "'.");
}
try (Writer fileWriter = Files.newBufferedWriter(this.typescriptFile.toPath(), StandardCharsets.UTF_8)) {
fileWriter.write(output);
} catch (IOException e) {
throw new MojoExecutionException("Cannot write DTO typescript file");
}
// attach this typescript file as maven artifact
projectHelper.attachArtifact(project, "ts", typescriptFile);
}
use of org.apache.maven.plugin.MojoExecutionException in project che by eclipse.
the class EffectivePomWriter method writeEffectivePom.
/**
* method from org.apache.maven.plugins.help.EffectivePomMojo
* Method for writing the effective pom informations of the current build.
*
* @param project the project of the current build, not null.
* @param writer the XML writer , not null, not null.
* @throws MojoExecutionException if any
*/
private static void writeEffectivePom(MavenProject project, XMLWriter writer) throws MojoExecutionException {
Model pom = project.getModel();
cleanModel(pom);
String effectivePom;
StringWriter sWriter = new StringWriter();
MavenXpp3Writer pomWriter = new MavenXpp3Writer();
try {
pomWriter.write(sWriter, pom);
} catch (IOException e) {
throw new MojoExecutionException("Cannot serialize POM to XML.", e);
}
effectivePom = addMavenNamespace(sWriter.toString(), true);
writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");
writer.writeMarkup(effectivePom);
}
Aggregations