use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.
the class AbstractSourceJarMojo method packageSources.
/**
* @param theProjects {@link MavenProject}
* @throws MojoExecutionException in case of an error.
*/
protected void packageSources(List<MavenProject> theProjects) throws MojoExecutionException {
if (project.getArtifact().getClassifier() != null) {
getLog().warn("NOT adding sources to artifacts with classifier as Maven only supports one classifier " + "per artifact. Current artifact [" + project.getArtifact().getId() + "] has a [" + project.getArtifact().getClassifier() + "] classifier.");
return;
}
MavenArchiver archiver = createArchiver();
for (MavenProject pItem : theProjects) {
MavenProject subProject = getProject(pItem);
if ("pom".equals(subProject.getPackaging())) {
continue;
}
archiveProjectContent(subProject, archiver.getArchiver());
}
if (archiver.getArchiver().getResources().hasNext() || forceCreation) {
if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) {
getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath());
archive.setManifestFile(defaultManifestFile);
}
File outputFile = new File(outputDirectory, finalName + "-" + getClassifier() + getExtension());
try {
archiver.setOutputFile(outputFile);
archive.setForced(forceCreation);
archiver.createArchive(session, project, archive);
} catch (IOException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (ArchiverException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
} catch (ManifestException e) {
throw new MojoExecutionException("Error creating source archive: " + e.getMessage(), e);
}
if (attach) {
projectHelper.attachArtifact(project, getType(), getClassifier(), outputFile);
} else {
getLog().info("NOT adding java-sources to attached artifacts list.");
}
} else {
getLog().info("No sources in project. Archive not created.");
}
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project generator by mybatis.
the class MyBatisGeneratorMojo method calculateClassPath.
private void calculateClassPath() throws MojoExecutionException {
if (includeCompileDependencies || includeAllDependencies) {
try {
// add the project compile classpath to the plugin classpath,
// so that the project dependency classes can be found
// directly, without adding the classpath to configuration's classPathEntries
// repeatedly.Examples are JDBC drivers, root classes, root interfaces, etc.
Set<String> entries = new HashSet<>();
if (includeCompileDependencies) {
entries.addAll(project.getCompileClasspathElements());
}
if (includeAllDependencies) {
entries.addAll(project.getTestClasspathElements());
}
// remove the output directories (target/classes and target/test-classes)
// because this mojo runs in the generate-sources phase and
// those directories have not been created yet (typically)
entries.remove(project.getBuild().getOutputDirectory());
entries.remove(project.getBuild().getTestOutputDirectory());
ClassLoader contextClassLoader = ClassloaderUtility.getCustomClassloader(entries);
Thread.currentThread().setContextClassLoader(contextClassLoader);
} catch (DependencyResolutionRequiredException e) {
throw new MojoExecutionException("Dependency Resolution Required", e);
}
}
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project cuke4duke by cucumber.
the class AbstractJRubyMojo method append.
protected void append(Path classPath, List<?> artifacts) throws DependencyResolutionRequiredException {
List<String> list = new ArrayList<String>(artifacts.size());
for (Object elem : artifacts) {
String path;
if (elem instanceof Artifact) {
Artifact a = (Artifact) elem;
File file = a.getFile();
if (file == null) {
throw new DependencyResolutionRequiredException(a);
}
path = file.getPath();
} else {
path = elem.toString();
}
list.add(path);
}
Path p = new Path(classPath.getProject());
p.setPath(StringUtils.join(list.iterator(), File.pathSeparator));
classPath.append(p);
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project xtext-xtend by eclipse.
the class XtendCompile method getClassPath.
@SuppressWarnings("deprecation")
protected List<String> getClassPath() {
Set<String> classPath = Sets.newLinkedHashSet();
classPath.add(project.getBuild().getSourceDirectory());
try {
classPath.addAll(project.getCompileClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new WrappedException(e);
}
addDependencies(classPath, project.getCompileArtifacts());
classPath.remove(project.getBuild().getOutputDirectory());
return newArrayList(filter(classPath, FILE_EXISTS));
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project xtext-xtend by eclipse.
the class XtendTestCompile method getTestClassPath.
@SuppressWarnings("deprecation")
protected List<String> getTestClassPath() {
Set<String> classPath = Sets.newLinkedHashSet();
classPath.add(project.getBuild().getTestSourceDirectory());
try {
classPath.addAll(project.getTestClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new WrappedException(e);
}
addDependencies(classPath, project.getTestArtifacts());
classPath.remove(project.getBuild().getTestOutputDirectory());
return newArrayList(filter(classPath, FILE_EXISTS));
}
Aggregations