use of org.apache.maven.artifact.DependencyResolutionRequiredException in project maven-plugins by apache.
the class JavadocJar method generateArchive.
// ----------------------------------------------------------------------
// private methods
// ----------------------------------------------------------------------
/**
* Method that creates the jar file
*
* @param javadocFiles the directory where the generated jar file will be put
* @param jarFileName the filename of the generated jar file
* @return a File object that contains the generated jar file
* @throws ArchiverException {@link ArchiverException}
* @throws IOException {@link IOException}
*/
private File generateArchive(File javadocFiles, String jarFileName) throws ArchiverException, IOException {
File javadocJar = new File(jarOutputDirectory, jarFileName);
if (javadocJar.exists()) {
javadocJar.delete();
}
MavenArchiver archiver = new MavenArchiver();
archiver.setArchiver(jarArchiver);
archiver.setOutputFile(javadocJar);
File contentDirectory = javadocFiles;
if (!contentDirectory.exists()) {
getLog().warn("JAR will be empty - no content was marked for inclusion!");
} else {
archiver.getArchiver().addDirectory(contentDirectory, DEFAULT_INCLUDES, DEFAULT_EXCLUDES);
}
List<Resource> resources = project.getBuild().getResources();
for (Resource r : resources) {
if (r.getDirectory().endsWith("maven-shared-archive-resources")) {
archiver.getArchiver().addDirectory(new File(r.getDirectory()));
}
}
if (useDefaultManifestFile && defaultManifestFile.exists() && archive.getManifestFile() == null) {
getLog().info("Adding existing MANIFEST to archive. Found under: " + defaultManifestFile.getPath());
archive.setManifestFile(defaultManifestFile);
}
try {
archiver.createArchive(session, project, archive);
} catch (ManifestException e) {
throw new ArchiverException("ManifestException: " + e.getMessage(), e);
} catch (DependencyResolutionRequiredException e) {
throw new ArchiverException("DependencyResolutionRequiredException: " + e.getMessage(), e);
}
return javadocJar;
}
use of org.apache.maven.artifact.DependencyResolutionRequiredException in project siddhi by wso2.
the class MarkdownDocumentationGenerationMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
// Finding the root maven project
MavenProject rootMavenProject = mavenProject;
if (loadFromAllJars) {
siddhiVersion = null;
}
while (rootMavenProject.getParent() != null && rootMavenProject.getParent().getBasedir() != null) {
rootMavenProject = rootMavenProject.getParent();
}
// Setting the relevant modules target directory if not set by user
String moduleTargetPath;
if (moduleTargetDirectory != null) {
moduleTargetPath = moduleTargetDirectory.getAbsolutePath();
} else {
moduleTargetPath = mavenProject.getBuild().getDirectory();
}
// Setting the documentation output directory if not set by user
String docGenBasePath;
if (docGenBaseDirectory != null) {
docGenBasePath = docGenBaseDirectory.getAbsolutePath();
} else {
docGenBasePath = rootMavenProject.getBasedir() + File.separator + Constants.DOCS_DIRECTORY;
}
// Setting the mkdocs config file path if not set by user
if (mkdocsConfigFile == null) {
mkdocsConfigFile = new File(rootMavenProject.getBasedir() + File.separator + Constants.MKDOCS_CONFIG_FILE_NAME + Constants.YAML_FILE_EXTENSION);
}
// Retrieving metadata
List<NamespaceMetaData> namespaceMetaDataList;
try {
namespaceMetaDataList = DocumentationUtils.getExtensionMetaData(moduleTargetPath, mavenProject.getRuntimeClasspathElements(), getLog(), includeOrigin, loadFromAllJars);
} catch (DependencyResolutionRequiredException e) {
throw new MojoFailureException("Unable to resolve dependencies of the project", e);
}
// Generating the documentation
if (namespaceMetaDataList.size() > 0) {
DocumentationUtils.generateDocumentation(namespaceMetaDataList, docGenBasePath, mavenProject.getVersion(), getLog(), siddhiVersion, mavenProject.getGroupId());
}
}
Aggregations