use of org.apache.maven.plugin.MojoExecutionException in project jangaroo-tools by CoreMedia.
the class JooTestMojo method executeSelenium.
void executeSelenium(String testsHtmlUrl) throws MojoExecutionException, MojoFailureException {
jooUnitSeleniumRCHost = System.getProperty("SELENIUM_RC_HOST", jooUnitSeleniumRCHost);
try {
//check wether the host is reachable
//noinspection ResultOfMethodCallIgnored
InetAddress.getAllByName(jooUnitSeleniumRCHost);
} catch (UnknownHostException e) {
throw new MojoExecutionException("Cannot resolve host " + jooUnitSeleniumRCHost + ". Please specify a host running the selenium remote control or skip tests" + " by -DskipTests", e);
}
getLog().info("JooTest report directory: " + testResultOutputDirectory.getAbsolutePath());
Selenium selenium = new DefaultSelenium(jooUnitSeleniumRCHost, jooUnitSeleniumRCPort, jooUnitSeleniumBrowserStartCommand, testsHtmlUrl);
try {
selenium.start();
getLog().debug("Opening " + testsHtmlUrl);
selenium.open(testsHtmlUrl);
getLog().debug("Waiting for test results for " + jooUnitTestExecutionTimeout + "ms ...");
selenium.waitForCondition("selenium.browserbot.getCurrentWindow().result != null || selenium.browserbot.getCurrentWindow().classLoadingError != null", "" + jooUnitTestExecutionTimeout);
String classLoadingError = selenium.getEval("selenium.browserbot.getCurrentWindow().classLoadingError");
if (classLoadingError != null && !classLoadingError.equals("null")) {
throw new MojoExecutionException(classLoadingError);
}
String testResultXml = selenium.getEval("selenium.browserbot.getCurrentWindow().result");
writeResultToFile(testResultXml);
evalTestOutput(new StringReader(testResultXml));
} catch (IOException e) {
throw new MojoExecutionException("Cannot write test results to file", e);
} catch (ParserConfigurationException e) {
throw new MojoExecutionException("Cannot create a simple XML Builder", e);
} catch (SAXException e) {
throw new MojoExecutionException("Cannot parse test result", e);
} catch (SeleniumException e) {
throw new MojoExecutionException("Selenium setup exception", e);
} finally {
selenium.stop();
}
}
use of org.apache.maven.plugin.MojoExecutionException in project jangaroo-tools by CoreMedia.
the class JooTestMojoBase method jettyRunTest.
protected Server jettyRunTest(boolean tryPortRange) throws MojoExecutionException {
JettyWebAppContext handler;
try {
handler = new JettyWebAppContext();
handler.setWebInfLib(findJars());
handler.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
List<Resource> baseResources = new ArrayList<Resource>();
baseResources.add(toResource(new File(outputDirectory, "META-INF/resources")));
baseResources.add(toResource(testOutputDirectory));
for (org.apache.maven.model.Resource r : testResources) {
File testResourceDirectory = new File(r.getDirectory());
if (testResourceDirectory.exists()) {
baseResources.add(toResource(testResourceDirectory));
}
}
handler.setBaseResource(new ResourceCollection(baseResources.toArray(new Resource[baseResources.size()])));
getLog().info("Using base resources " + baseResources);
ServletHolder servletHolder = new ServletHolder("default", DefaultServlet.class);
servletHolder.setInitParameter("cacheControl", "no-store, no-cache, must-revalidate, max-age=0");
handler.addServlet(servletHolder, "/");
getLog().info("Set servlet cache control to 'do not cache'.");
} catch (Exception e) {
throw wrap(e);
}
return startJetty(handler, tryPortRange);
}
use of org.apache.maven.plugin.MojoExecutionException in project kotlin by JetBrains.
the class ExecuteKotlinScriptMojo method getKotlinRuntimeDependencies.
private List<File> getKotlinRuntimeDependencies() throws MojoExecutionException {
Artifact stdlibDep = null;
Artifact runtimeDep = null;
ArrayList<File> files = new ArrayList<File>(2);
for (Artifact dep : project.getArtifacts()) {
if (dep.getArtifactId().equals("kotlin-stdlib")) {
files.add(getArtifactFile(dep));
stdlibDep = dep;
}
if (dep.getArtifactId().equals("kotlin-runtime")) {
files.add(getArtifactFile(dep));
runtimeDep = dep;
}
if (stdlibDep != null && runtimeDep != null)
break;
}
if (stdlibDep == null) {
throw new MojoExecutionException("Unable to find kotlin-stdlib artifacts among project dependencies");
}
return files;
}
use of org.apache.maven.plugin.MojoExecutionException in project aries by apache.
the class GenerateMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
List<String> toScan = getPackagesToScan();
if (!sourcesChanged()) {
getLog().info("Skipping blueprint generation because source files were not changed");
return;
}
BlueprintConfigurationImpl blueprintConfiguration = new BlueprintConfigurationImpl(namespaces, defaultActivation, customParameters);
try {
ClassFinder classFinder = createProjectScopeFinder();
Set<Class<?>> classes = FilteredClassFinder.findClasses(classFinder, toScan);
Blueprint blueprint = new Blueprint(blueprintConfiguration, classes);
writeBlueprintIfNeeded(blueprint);
} catch (Exception e) {
throw new MojoExecutionException("Error building commands help", e);
}
}
use of org.apache.maven.plugin.MojoExecutionException in project aries by apache.
the class EbaMojo method writeApplicationManifest.
private void writeApplicationManifest(String fileName) throws MojoExecutionException {
try {
// TODO: add support for dependency version ranges. Need to pick
// them up from the pom and convert them to OSGi version ranges.
FileUtils.fileAppend(fileName, MANIFEST_VERSION + ": " + "1" + "\n");
FileUtils.fileAppend(fileName, APPLICATION_MANIFESTVERSION + ": " + "1" + "\n");
FileUtils.fileAppend(fileName, APPLICATION_SYMBOLICNAME + ": " + getApplicationSymbolicName(project.getArtifact()) + "\n");
FileUtils.fileAppend(fileName, APPLICATION_VERSION + ": " + getApplicationVersion() + "\n");
FileUtils.fileAppend(fileName, APPLICATION_NAME + ": " + project.getName() + "\n");
FileUtils.fileAppend(fileName, APPLICATION_DESCRIPTION + ": " + project.getDescription() + "\n");
// Write the APPLICATION-CONTENT
// TODO: check that the dependencies are bundles (currently, the converter
// will throw an exception)
Set<Artifact> artifacts;
if (useTransitiveDependencies) {
artifacts = project.getArtifacts();
} else {
artifacts = project.getDependencyArtifacts();
}
artifacts = selectArtifacts(artifacts);
Iterator<Artifact> iter = artifacts.iterator();
FileUtils.fileAppend(fileName, APPLICATION_CONTENT + ": ");
if (iter.hasNext()) {
Artifact artifact = iter.next();
FileUtils.fileAppend(fileName, maven2OsgiConverter.getBundleSymbolicName(artifact) + ";version=\"" + Analyzer.cleanupVersion(artifact.getVersion()) + // + maven2OsgiConverter.getVersion(artifact.getVersion())
"\"");
}
while (iter.hasNext()) {
Artifact artifact = iter.next();
FileUtils.fileAppend(fileName, ",\n " + maven2OsgiConverter.getBundleSymbolicName(artifact) + ";version=\"" + Analyzer.cleanupVersion(artifact.getVersion()) + // + maven2OsgiConverter.getVersion(artifact.getVersion())
"\"");
}
FileUtils.fileAppend(fileName, "\n");
// Add any service imports or exports
if (instructions.containsKey(APPLICATION_EXPORTSERVICE)) {
FileUtils.fileAppend(fileName, APPLICATION_EXPORTSERVICE + ": " + instructions.get(APPLICATION_EXPORTSERVICE) + "\n");
}
if (instructions.containsKey(APPLICATION_IMPORTSERVICE)) {
FileUtils.fileAppend(fileName, APPLICATION_IMPORTSERVICE + ": " + instructions.get(APPLICATION_IMPORTSERVICE) + "\n");
}
if (instructions.containsKey(APPLICATION_USEBUNDLE)) {
FileUtils.fileAppend(fileName, APPLICATION_USEBUNDLE + ": " + instructions.get(APPLICATION_USEBUNDLE) + "\n");
}
// Add any use bundle entry
} catch (Exception e) {
throw new MojoExecutionException("Error writing dependencies into APPLICATION.MF", e);
}
}
Aggregations