Search in sources :

Example 36 with DependencyResolutionRequiredException

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;
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) Resource(org.apache.maven.model.Resource) MavenArchiver(org.apache.maven.archiver.MavenArchiver) ManifestException(org.codehaus.plexus.archiver.jar.ManifestException) File(java.io.File)

Example 37 with DependencyResolutionRequiredException

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());
    }
}
Also used : DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) MavenProject(org.apache.maven.project.MavenProject) NamespaceMetaData(io.siddhi.doc.gen.metadata.NamespaceMetaData) MojoFailureException(org.apache.maven.plugin.MojoFailureException) File(java.io.File)

Aggregations

DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)37 File (java.io.File)25 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)16 IOException (java.io.IOException)12 ArchiverException (org.codehaus.plexus.archiver.ArchiverException)11 ManifestException (org.codehaus.plexus.archiver.jar.ManifestException)11 MavenArchiver (org.apache.maven.archiver.MavenArchiver)10 MojoFailureException (org.apache.maven.plugin.MojoFailureException)9 ArrayList (java.util.ArrayList)8 MavenProject (org.apache.maven.project.MavenProject)8 MalformedURLException (java.net.MalformedURLException)6 URLClassLoader (java.net.URLClassLoader)6 URL (java.net.URL)5 FileNotFoundException (java.io.FileNotFoundException)3 HashSet (java.util.HashSet)3 Resource (org.apache.maven.model.Resource)3 Path (org.apache.tools.ant.types.Path)3 NamespaceMetaData (io.siddhi.doc.gen.metadata.NamespaceMetaData)2 Path (java.nio.file.Path)2 List (java.util.List)2