use of org.apache.maven.plugin.MojoFailureException in project karaf by apache.
the class Dependency31Helper method resolveById.
@Override
public File resolveById(String id, Log log) throws MojoFailureException {
if (id.startsWith("mvn:")) {
if (id.contains("!")) {
id = id.substring(0, "mvn:".length()) + id.substring(id.indexOf("!") + 1);
}
if (id.endsWith("/")) {
id = id.substring(0, id.length() - 1);
}
}
id = MavenUtil.mvnToAether(id);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(id));
request.setRepositories(projectRepositories);
log.debug("Resolving artifact " + id + " from " + projectRepositories);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repositorySystemSession, request);
} catch (ArtifactResolutionException e) {
log.warn("Could not resolve " + id, e);
throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e);
}
log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
return result.getArtifact().getFile();
}
use of org.apache.maven.plugin.MojoFailureException in project karaf by apache.
the class GenerateHelpMojo method createFinder.
private ClassFinder createFinder(String classloaderType) throws Exception {
ClassFinder finder;
if ("project".equals(classloaderType)) {
List<URL> urls = new ArrayList<>();
for (Object object : project.getCompileClasspathElements()) {
String path = (String) object;
urls.add(new File(path).toURI().toURL());
}
ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
finder = new ClassFinder(loader, urls);
} else if ("plugin".equals(classLoader)) {
finder = new ClassFinder(getClass().getClassLoader());
} else {
throw new MojoFailureException("classLoader attribute must be 'project' or 'plugin'");
}
return finder;
}
use of org.apache.maven.plugin.MojoFailureException in project karaf by apache.
the class ExportFeatureMetaDataMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
Set<Feature> featuresSet = resolveFeatures();
if (mergedFeature) {
Feature feature = oneVersion ? mergeFeatureOneVersion(featuresSet) : mergeFeature(featuresSet);
featuresSet = new HashSet<>();
featuresSet.add(feature);
}
try {
metaDataFile.getParentFile().mkdirs();
Features features = new Features();
features.getFeature().addAll(featuresSet);
try (OutputStream os = new FileOutputStream(metaDataFile)) {
JaxbUtil.marshal(features, os);
}
} catch (Exception e) {
throw new RuntimeException("Error writing feature meta data to " + metaDataFile + ": " + e.getMessage(), e);
}
}
use of org.apache.maven.plugin.MojoFailureException in project karaf by apache.
the class ArchiveMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().debug("Setting artifact file: " + targetFile);
org.apache.maven.artifact.Artifact artifact = project.getArtifact();
artifact.setFile(targetFile);
try {
//now pack up the server.
if (archiveTarGz) {
archive("tar.gz");
}
if (archiveZip) {
archive("zip");
}
} catch (Exception e) {
throw new MojoExecutionException("Could not archive plugin", e);
}
}
use of org.apache.maven.plugin.MojoFailureException in project karaf by apache.
the class RunMojo method execute.
public void execute() throws MojoExecutionException, MojoFailureException {
if (karafDirectory.exists()) {
getLog().info("Using Karaf container located " + karafDirectory.getAbsolutePath());
} else {
getLog().info("Extracting Karaf container");
try {
File karafArchiveFile = resolveFile(karafDistribution);
extract(karafArchiveFile, karafDirectory);
} catch (Exception e) {
throw new MojoFailureException("Can't extract Karaf container", e);
}
}
getLog().info("Starting Karaf container");
System.setProperty("karaf.home", karafDirectory.getAbsolutePath());
System.setProperty("karaf.base", karafDirectory.getAbsolutePath());
System.setProperty("karaf.data", karafDirectory.getAbsolutePath() + "/data");
System.setProperty("karaf.etc", karafDirectory.getAbsolutePath() + "/etc");
System.setProperty("karaf.instances", karafDirectory.getAbsolutePath() + "/instances");
System.setProperty("karaf.startLocalConsole", "false");
System.setProperty("karaf.startRemoteShell", startSsh);
System.setProperty("karaf.lock", "false");
Main main = new Main(new String[0]);
try {
main.launch();
while (main.getFramework().getState() != Bundle.ACTIVE) {
Thread.sleep(1000);
}
BundleContext bundleContext = main.getFramework().getBundleContext();
Object bootFinished = null;
while (bootFinished == null) {
Thread.sleep(1000);
ServiceReference ref = bundleContext.getServiceReference(BootFinished.class);
if (ref != null) {
bootFinished = bundleContext.getService(ref);
}
}
deploy(bundleContext);
if (keepRunning)
main.awaitShutdown();
main.destroy();
} catch (Throwable e) {
throw new MojoExecutionException("Can't start container", e);
} finally {
System.gc();
}
}
Aggregations