use of org.apache.maven.plugin.MojoExecutionException in project karaf by apache.
the class Dependency31Helper method getDependencyTree.
private DependencyNode getDependencyTree(Artifact artifact) throws MojoExecutionException {
try {
CollectRequest collectRequest = new CollectRequest(new Dependency(artifact, "compile"), null, projectRepositories);
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
session.setDependencySelector(new AndDependencySelector(new OptionalDependencySelector(), new ScopeDependencySelector1(), new ExclusionDependencySelector()));
// between aether-util 0.9.0.M1 and M2, JavaEffectiveScopeCalculator was removed
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=397241
DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new ConflictMarker(), new ConflictResolver(new NearestVersionSelector(), new JavaScopeSelector(), new SimpleOptionalitySelector(), new JavaScopeDeriver()), new JavaDependencyContextRefiner());
session.setDependencyGraphTransformer(transformer);
CollectResult result = repositorySystem.collectDependencies(session, collectRequest);
return result.getRoot();
} catch (DependencyCollectionException e) {
throw new MojoExecutionException("Cannot build project dependency tree", e);
}
}
use of org.apache.maven.plugin.MojoExecutionException in project karaf by apache.
the class AbstractFeatureMojo method resolveFeatures.
protected Set<Feature> resolveFeatures() throws MojoExecutionException {
Set<Feature> featuresSet = new HashSet<>();
try {
Set<String> artifactsToCopy = new HashSet<>();
Map<String, Feature> featuresMap = new HashMap<>();
for (String uri : descriptors) {
retrieveDescriptorsRecursively(uri, artifactsToCopy, featuresMap);
}
// no features specified, handle all of them
if (features == null) {
features = new ArrayList<>(featuresMap.keySet());
}
addFeatures(features, featuresSet, featuresMap, addTransitiveFeatures);
getLog().info("Using local repository at: " + localRepo.getUrl());
for (Feature feature : featuresSet) {
try {
for (Bundle bundle : feature.getBundle()) {
resolveArtifact(bundle.getLocation());
}
for (Conditional conditional : feature.getConditional()) {
for (BundleInfo bundle : conditional.getBundles()) {
if (ignoreDependencyFlag || (!ignoreDependencyFlag && !bundle.isDependency())) {
resolveArtifact(bundle.getLocation());
}
}
}
for (ConfigFile configfile : feature.getConfigfile()) {
resolveArtifact(configfile.getLocation());
}
} catch (RuntimeException e) {
throw new RuntimeException("Error resolving feature " + feature.getName() + "/" + feature.getVersion(), e);
}
}
} catch (Exception e) {
throw new MojoExecutionException("Error populating repository", e);
}
return featuresSet;
}
use of org.apache.maven.plugin.MojoExecutionException 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.MojoExecutionException in project karaf by apache.
the class AbstractFeatureMojo method addFeatureRepo.
protected void addFeatureRepo(String featureUrl) throws MojoExecutionException {
Artifact featureDescArtifact = resourceToArtifact(featureUrl, true);
if (featureDescArtifact == null) {
return;
}
try {
resolveArtifact(featureDescArtifact, remoteRepos);
descriptors.add(0, featureUrl);
} catch (Exception e) {
getLog().warn("Can't add " + featureUrl + " in the descriptors set");
getLog().debug(e);
}
}
use of org.apache.maven.plugin.MojoExecutionException in project asterixdb by apache.
the class LexerGeneratorMojo method execute.
public void execute() throws MojoExecutionException {
LexerGenerator lexer = new LexerGenerator(getLog());
HashMap<String, String> config = new HashMap<String, String>();
getLog().info("--- Lexer Generator Maven Plugin - started with grammarFile: " + grammarFile.toString());
try {
String input = readFile(grammarFile);
config.put("OUTPUT_DIR", outputDir.toString());
boolean tokens = false;
for (String line : input.split("\r?\n")) {
line = line.trim();
if (line.length() == 0 || line.charAt(0) == '#')
continue;
if (tokens == false && !line.equals("TOKENS:")) {
config.put(line.split("\\s*:\\s*")[0], line.split("\\s*:\\s*")[1]);
} else if (line.equals("TOKENS:")) {
tokens = true;
} else {
lexer.addToken(line);
}
}
lexer.generateLexer(config);
} catch (Throwable e) {
throw new MojoExecutionException("Error while generating lexer", e);
}
String parsedGrammar = lexer.printParsedGrammar();
getLog().info("--- Generated grammar:\n" + parsedGrammar);
}
Aggregations