Example usage for org.apache.maven.artifact.repository.layout ArtifactRepositoryLayout pathOf

List of usage examples for org.apache.maven.artifact.repository.layout ArtifactRepositoryLayout pathOf

Introduction

In this page you can find the example usage for org.apache.maven.artifact.repository.layout ArtifactRepositoryLayout pathOf.

Prototype

String pathOf(Artifact artifact);

Source Link

Usage

From source file:io.github.appbundler.CreateApplicationBundleMojo.java

License:Apache License

/**
 * Copy all dependencies into the $JAVAROOT directory
 *
 * @param javaDirectory where to put jar files
 * @return A list of file names added/* www.  j  a v  a 2s. c  o  m*/
 * @throws MojoExecutionException
 */
private List<String> copyDependencies(File javaDirectory) throws MojoExecutionException {

    ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

    List<String> list = new ArrayList<String>();

    //        File repoDirectory = new File(javaDirectory, "repo");
    //        repoDirectory.mkdirs();

    // First, copy the project's own artifact
    File artifactFile = project.getArtifact().getFile();
    list.add(layout.pathOf(project.getArtifact()));

    try {
        FileUtils.copyFile(artifactFile, new File(javaDirectory, layout.pathOf(project.getArtifact())));
    } catch (IOException e) {
        throw new MojoExecutionException(
                "Could not copy artifact file " + artifactFile + " to " + javaDirectory);
    }

    Set<Artifact> artifacts = project.getArtifacts();

    Iterator<Artifact> i = artifacts.iterator();

    while (i.hasNext()) {
        Artifact artifact = i.next();

        File file = artifact.getFile();
        File dest = new File(javaDirectory, layout.pathOf(artifact));

        getLog().debug("Adding " + file);

        try {
            FileUtils.copyFile(file, dest);
        } catch (IOException e) {
            throw new MojoExecutionException("Error copying file " + file + " into " + javaDirectory, e);
        }

        list.add(layout.pathOf(artifact));
    }

    return list;
}

From source file:org.apache.karaf.tooling.features.CreateKarMojo.java

License:Apache License

/**
 * Generates the configuration archive.//from   www .ja  va2 s  . c o m
 *
 * @param bundles
 */
@SuppressWarnings("deprecation")
private File createArchive(List<Artifact> bundles, File featuresFile, String groupId, String artifactId,
        String version) throws MojoExecutionException {
    ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
    File archiveFile = getArchiveFile(outputDirectory, finalName, classifier);

    MavenArchiver archiver = new MavenArchiver();
    archiver.setArchiver(jarArchiver);
    archiver.setOutputFile(archiveFile);

    try {
        //TODO should .kar be a bundle?
        //            archive.addManifestEntry(Constants.BUNDLE_NAME, project.getName());
        //            archive.addManifestEntry(Constants.BUNDLE_VENDOR, project.getOrganization().getName());
        //            ArtifactVersion version = project.getArtifact().getSelectedVersion();
        //            String versionString = "" + version.getMajorVersion() + "." + version.getMinorVersion() + "." + version.getIncrementalVersion();
        //            if (version.getQualifier() != null) {
        //                versionString += "." + version.getQualifier();
        //            }
        //            archive.addManifestEntry(Constants.BUNDLE_VERSION, versionString);
        //            archive.addManifestEntry(Constants.BUNDLE_MANIFESTVERSION, "2");
        //            archive.addManifestEntry(Constants.BUNDLE_DESCRIPTION, project.getDescription());
        //            // NB, no constant for this one
        //            archive.addManifestEntry("Bundle-License", ((License) project.getLicenses().get(0)).getUrl());
        //            archive.addManifestEntry(Constants.BUNDLE_DOCURL, project.getUrl());
        //            //TODO this might need some help
        //            archive.addManifestEntry(Constants.BUNDLE_SYMBOLICNAME, project.getArtifactId());

        //include the feature.xml
        Artifact featureArtifact = factory.createArtifactWithClassifier(groupId, artifactId, version, "xml",
                KarArtifactInstaller.FEATURE_CLASSIFIER);
        jarArchiver.addFile(featuresFile, repositoryPath + layout.pathOf(featureArtifact));

        if (featureArtifact.isSnapshot()) {
            // the artifact is a snapshot, create the maven-metadata-local.xml
            getLog().debug("Feature artifact is a SNAPSHOT, handling the maven-metadata-local.xml");
            File metadataTarget = new File(featuresFile.getParentFile(), "maven-metadata-local.xml");
            getLog().debug("Looking for " + metadataTarget.getAbsolutePath());
            if (!metadataTarget.exists()) {
                // the maven-metadata-local.xml doesn't exist, create it
                getLog().debug(metadataTarget.getAbsolutePath() + " doesn't exist, create it");
                Metadata metadata = new Metadata();
                metadata.setGroupId(featureArtifact.getGroupId());
                metadata.setArtifactId(featureArtifact.getArtifactId());
                metadata.setVersion(featureArtifact.getVersion());
                metadata.setModelVersion("1.1.0");

                Versioning versioning = new Versioning();
                versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
                Snapshot snapshot = new Snapshot();
                snapshot.setLocalCopy(true);
                versioning.setSnapshot(snapshot);
                SnapshotVersion snapshotVersion = new SnapshotVersion();
                snapshotVersion.setClassifier(featureArtifact.getClassifier());
                snapshotVersion.setVersion(featureArtifact.getVersion());
                snapshotVersion.setExtension(featureArtifact.getType());
                snapshotVersion.setUpdated(versioning.getLastUpdated());
                versioning.addSnapshotVersion(snapshotVersion);

                metadata.setVersioning(versioning);

                MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
                try {
                    Writer writer = new FileWriter(metadataTarget);
                    metadataWriter.write(writer, metadata);
                } catch (Exception e) {
                    getLog().warn("Could not create maven-metadata-local.xml", e);
                    getLog().warn(
                            "It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                }
            }
            getLog().debug(
                    "Adding file " + metadataTarget.getAbsolutePath() + " in the jar path " + repositoryPath
                            + layout.pathOf(featureArtifact).substring(0,
                                    layout.pathOf(featureArtifact).lastIndexOf('/'))
                            + "/maven-metadata-local.xml");
            jarArchiver.addFile(metadataTarget,
                    repositoryPath
                            + layout.pathOf(featureArtifact).substring(0,
                                    layout.pathOf(featureArtifact).lastIndexOf('/'))
                            + "/maven-metadata-local.xml");
        }

        for (Artifact artifact : bundles) {
            resolver.resolve(artifact, remoteRepos, localRepo);
            File localFile = artifact.getFile();

            if (artifact.isSnapshot()) {
                // the artifact is a snapshot, create the maven-metadata-local.xml
                File metadataTarget = new File(localFile.getParentFile(), "maven-metadata-local.xml");
                if (!metadataTarget.exists()) {
                    // the maven-metadata-local.xml doesn't exist, create it
                    try {
                        MavenUtil.generateMavenMetadata(artifact, metadataTarget);
                    } catch (Exception e) {
                        getLog().warn("Could not create maven-metadata-local.xml", e);
                        getLog().warn(
                                "It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                    }
                }
                jarArchiver.addFile(metadataTarget,
                        repositoryPath
                                + layout.pathOf(artifact).substring(0, layout.pathOf(artifact).lastIndexOf('/'))
                                + "/maven-metadata-local.xml");
            }

            //TODO this may not be reasonable, but... resolved snapshot artifacts have timestamped versions
            //which do not work in startup.properties.
            artifact.setVersion(artifact.getBaseVersion());
            String targetFileName = repositoryPath + layout.pathOf(artifact);
            jarArchiver.addFile(localFile, targetFileName);
        }

        if (resourcesDir.isDirectory()) {
            archiver.getArchiver().addDirectory(resourcesDir);
        }
        archiver.createArchive(project, archive);

        return archiveFile;
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to create archive", e);
    }
}

From source file:org.apache.karaf.tooling.KarMojo.java

License:Apache License

/**
 * Generates the configuration archive./*from www. j  a  va 2s. co  m*/
 *
 * @param bundles
 */
@SuppressWarnings("deprecation")
private File createArchive(List<Artifact> bundles, File featuresFile, String groupId, String artifactId,
        String version) throws MojoExecutionException {
    ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();
    File archiveFile = getArchiveFile(outputDirectory, finalName, classifier);

    MavenArchiver archiver = new MavenArchiver();
    archiver.setArchiver(jarArchiver);
    archiver.setOutputFile(archiveFile);

    try {
        //TODO should .kar be a bundle?
        //            archive.addManifestEntry(Constants.BUNDLE_NAME, project.getName());
        //            archive.addManifestEntry(Constants.BUNDLE_VENDOR, project.getOrganization().getName());
        //            ArtifactVersion version = project.getArtifact().getSelectedVersion();
        //            String versionString = "" + version.getMajorVersion() + "." + version.getMinorVersion() + "." + version.getIncrementalVersion();
        //            if (version.getQualifier() != null) {
        //                versionString += "." + version.getQualifier();
        //            }
        //            archive.addManifestEntry(Constants.BUNDLE_VERSION, versionString);
        //            archive.addManifestEntry(Constants.BUNDLE_MANIFESTVERSION, "2");
        //            archive.addManifestEntry(Constants.BUNDLE_DESCRIPTION, project.getDescription());
        //            // NB, no constant for this one
        //            archive.addManifestEntry("Bundle-License", ((License) project.getLicenses().get(0)).getUrl());
        //            archive.addManifestEntry(Constants.BUNDLE_DOCURL, project.getUrl());
        //            //TODO this might need some help
        //            archive.addManifestEntry(Constants.BUNDLE_SYMBOLICNAME, project.getArtifactId());

        //include the feature.xml
        Artifact featureArtifact = factory.createArtifactWithClassifier(groupId, artifactId, version, "xml",
                KarArtifactInstaller.FEATURE_CLASSIFIER);
        jarArchiver.addFile(featuresFile, repositoryPath + layout.pathOf(featureArtifact));

        if (featureArtifact.isSnapshot()) {
            // the artifact is a snapshot, create the maven-metadata-local.xml
            getLog().debug("Feature artifact is a SNAPSHOT, handling the maven-metadata-local.xml");
            File metadataTarget = new File(featuresFile.getParentFile(), "maven-metadata-local.xml");
            getLog().debug("Looking for " + metadataTarget.getAbsolutePath());
            if (!metadataTarget.exists()) {
                // the maven-metadata-local.xml doesn't exist, create it
                getLog().debug(metadataTarget.getAbsolutePath() + " doesn't exist, create it");
                Metadata metadata = new Metadata();
                metadata.setGroupId(featureArtifact.getGroupId());
                metadata.setArtifactId(featureArtifact.getArtifactId());
                metadata.setVersion(featureArtifact.getVersion());
                metadata.setModelVersion("1.1.0");

                Versioning versioning = new Versioning();
                versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
                Snapshot snapshot = new Snapshot();
                snapshot.setLocalCopy(true);
                versioning.setSnapshot(snapshot);
                SnapshotVersion snapshotVersion = new SnapshotVersion();
                snapshotVersion.setClassifier(featureArtifact.getClassifier());
                snapshotVersion.setVersion(featureArtifact.getVersion());
                snapshotVersion.setExtension(featureArtifact.getType());
                snapshotVersion.setUpdated(versioning.getLastUpdated());
                versioning.addSnapshotVersion(snapshotVersion);

                metadata.setVersioning(versioning);

                MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
                try {
                    Writer writer = new FileWriter(metadataTarget);
                    metadataWriter.write(writer, metadata);
                } catch (Exception e) {
                    getLog().warn("Could not create maven-metadata-local.xml", e);
                    getLog().warn(
                            "It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                }
            }
            getLog().debug(
                    "Adding file " + metadataTarget.getAbsolutePath() + " in the jar path " + repositoryPath
                            + layout.pathOf(featureArtifact).substring(0,
                                    layout.pathOf(featureArtifact).lastIndexOf('/'))
                            + "/maven-metadata-local.xml");
            jarArchiver.addFile(metadataTarget,
                    repositoryPath
                            + layout.pathOf(featureArtifact).substring(0,
                                    layout.pathOf(featureArtifact).lastIndexOf('/'))
                            + "/maven-metadata-local.xml");
        }

        for (Artifact artifact : bundles) {
            artifactResolver.resolve(artifact, remoteRepos, localRepo);
            File localFile = artifact.getFile();

            if (artifact.isSnapshot()) {
                // the artifact is a snapshot, create the maven-metadata-local.xml
                File metadataTarget = new File(localFile.getParentFile(), "maven-metadata-local.xml");
                if (!metadataTarget.exists()) {
                    // the maven-metadata-local.xml doesn't exist, create it
                    try {
                        MavenUtil.generateMavenMetadata(artifact, metadataTarget);
                    } catch (Exception e) {
                        getLog().warn("Could not create maven-metadata-local.xml", e);
                        getLog().warn(
                                "It means that this SNAPSHOT could be overwritten by an older one present on remote repositories");
                    }
                }
                jarArchiver.addFile(metadataTarget,
                        repositoryPath
                                + layout.pathOf(artifact).substring(0, layout.pathOf(artifact).lastIndexOf('/'))
                                + "/maven-metadata-local.xml");
            }

            //TODO this may not be reasonable, but... resolved snapshot artifacts have timestamped versions
            //which do not work in startup.properties.
            artifact.setVersion(artifact.getBaseVersion());
            String targetFileName = repositoryPath + layout.pathOf(artifact);
            jarArchiver.addFile(localFile, targetFileName);
        }

        if (resourcesDir.isDirectory()) {
            archiver.getArchiver().addDirectory(resourcesDir);
        }
        archiver.createArchive(project, archive);

        return archiveFile;
    } catch (Exception e) {
        throw new MojoExecutionException("Failed to create archive", e);
    }
}

From source file:org.codehaus.mojo.appassembler.AssembleMojo.java

License:Open Source License

private org.codehaus.mojo.appassembler.model.Daemon programToDaemon(Program program,
        ArtifactRepositoryLayout artifactRepositoryLayout) {
    org.codehaus.mojo.appassembler.model.Daemon daemon = new org.codehaus.mojo.appassembler.model.Daemon();

    daemon.setId(program.getName());/*from  w ww.  j av a 2s.c  om*/
    daemon.setMainClass(program.getMainClass());
    daemon.setShowConsoleWindow(showConsoleWindow);
    daemon.setCommandLineArguments(program.getCommandLineArguments());

    if (program.getLicenseHeaderFile() != null) {
        getLog().debug("Using the program specific license header. :" + program.getLicenseHeaderFile());
        daemon.setLicenseHeaderFile(program.getLicenseHeaderFile().getPath());
    } else {
        getLog().debug("Using the global defined license header. :" + licenseHeaderFile);

        if (licenseHeaderFile != null) {
            daemon.setLicenseHeaderFile(this.licenseHeaderFile.getAbsolutePath());
        } else {
            daemon.setLicenseHeaderFile(null);
        }
    }

    List directories = new ArrayList();

    if (includeConfigurationDirectoryInClasspath) {
        Directory directory = new Directory();
        directory.setRelativePath(configurationDirectory);
        directories.add(directory);
    }

    if (daemon.getClasspath() == null) {
        daemon.setClasspath(new Classpath());
    }

    daemon.getClasspath().setDirectories(directories);

    daemon.setRepositoryName(repositoryName);

    List dependencies = new ArrayList();

    // TODO: This should be done in a more elegant way for 2.0
    // TODO: Check if the classpath wildcard could be used for Daemons as well?

    // TODO: Remove the isUseAsterikClassPath with release 1.3 ?
    if (isUseAsterikClassPath() || isUseWildcardClassPath()) {
        Dependency dependency = new Dependency();
        dependency.setGroupId("");
        dependency.setArtifactId("");
        dependency.setVersion("");
        dependency.setRelativePath("*");
        dependencies.add(dependency);
    } else {
        List classPathArtifacts = new ArrayList();

        if (isProjectArtifactFirstInClassPath()) {
            classPathArtifacts.add(projectArtifact);
            classPathArtifacts.addAll(artifacts);
        } else {
            classPathArtifacts.addAll(artifacts);
            classPathArtifacts.add(projectArtifact);
        }

        for (Iterator it = classPathArtifacts.iterator(); it.hasNext();) {
            Artifact artifact = (Artifact) it.next();
            Dependency dependency = new Dependency();
            dependency.setGroupId(artifact.getGroupId());
            dependency.setArtifactId(artifact.getArtifactId());
            dependency.setVersion(artifact.getVersion());
            dependency.setRelativePath(artifactRepositoryLayout.pathOf(artifact));
            if (artifact.isSnapshot() && !this.useTimestampInSnapshotFileName) {
                dependency.setRelativePath(ArtifactUtils.pathBaseVersionOf(artifactRepositoryLayout, artifact));
            }

            dependencies.add(dependency);
        }

    }

    daemon.getClasspath().setDependencies(dependencies);

    daemon.setJvmSettings(convertToJvmSettingsWithDefaultHandling(program));

    daemon.setEnvironmentSetupFileName(this.environmentSetupFileName);

    if (this.unixScriptTemplate != null) {
        daemon.setUnixScriptTemplate(unixScriptTemplate);
    }
    if (this.windowsScriptTemplate != null) {
        daemon.setWindowsScriptTemplate(windowsScriptTemplate);
    }

    return daemon;
}

From source file:org.codehaus.mojo.appassembler.daemon.booter.AbstractBooterDaemonGenerator.java

License:Open Source License

private static Dependency createDependency(MavenProject project, String id,
        ArtifactRepositoryLayout artifactRepositoryLayout) throws DaemonGeneratorException {
    Artifact artifact = (Artifact) project.getArtifactMap().get(id);

    if (artifact == null) {
        throw new DaemonGeneratorException("The project has to have a dependency on '" + id + "'.");
    }//w  ww  .j  a v a2 s . c  o m

    Dependency dependency = new Dependency();

    dependency.setRelativePath(artifactRepositoryLayout.pathOf(artifact));
    return dependency;
}

From source file:org.codehaus.mojo.appassembler.daemon.generic.GenericDaemonGenerator.java

License:Open Source License

private Daemon createDaemon(MavenProject project, ArtifactRepositoryLayout layout) {
    Daemon complete = new Daemon();

    complete.setClasspath(new Classpath());

    // -----------------------------------------------------------------------
    // Add the project itself as a dependency.
    // -----------------------------------------------------------------------
    Dependency projectDependency = new Dependency();
    Artifact projectArtifact = project.getArtifact();
    projectArtifact.isSnapshot();/*from   w  ww . ja va2  s. c  o m*/
    projectDependency.setGroupId(projectArtifact.getGroupId());
    projectDependency.setArtifactId(projectArtifact.getArtifactId());
    projectDependency.setVersion(projectArtifact.getVersion());
    projectDependency.setClassifier(projectArtifact.getClassifier());
    projectDependency.setRelativePath(layout.pathOf(projectArtifact));
    complete.getClasspath().addDependency(projectDependency);

    // -----------------------------------------------------------------------
    // Add all the dependencies of the project.
    // -----------------------------------------------------------------------
    for (Iterator it = project.getRuntimeArtifacts().iterator(); it.hasNext();) {
        Artifact artifact = (Artifact) it.next();

        artifact.isSnapshot();

        Dependency dependency = new Dependency();
        dependency.setGroupId(artifact.getGroupId());
        dependency.setArtifactId(artifact.getArtifactId());
        dependency.setVersion(artifact.getVersion());

        dependency.setClassifier(artifact.getClassifier());
        dependency.setRelativePath(layout.pathOf(artifact));

        complete.getClasspath().addDependency(dependency);
    }

    return complete;
}

From source file:org.codehaus.mojo.appassembler.daemon.jsw.JavaServiceWrapperDaemonGenerator.java

License:Open Source License

private Dependency createDependency(ArtifactRepositoryLayout layout, Artifact artifact,
        boolean useTimestampInSnapshotFileName) {
    Dependency dependency = new Dependency();
    dependency.setArtifactId(artifact.getArtifactId());
    dependency.setGroupId(artifact.getGroupId());
    dependency.setVersion(artifact.getVersion());
    dependency.setRelativePath(layout.pathOf(artifact));
    if (artifact.isSnapshot() && !useTimestampInSnapshotFileName) {
        dependency.setRelativePath(ArtifactUtils.pathBaseVersionOf(layout, artifact));
    }/*  w w w.  j  a v  a2  s.c om*/

    return dependency;
}

From source file:org.codehaus.mojo.appassembler.util.ArtifactUtils.java

License:Open Source License

/**
 * get relative path the copied artifact using base version. This is mainly use to SNAPSHOT instead of timestamp in
 * the file name//from w  w w .ja  va  2s. c  o  m
 * 
 * @param artifactRepositoryLayout
 * @param artifact
 * @return
 */
public static String pathBaseVersionOf(ArtifactRepositoryLayout artifactRepositoryLayout, Artifact artifact) {
    ArtifactHandler artifactHandler = artifact.getArtifactHandler();

    StringBuffer fileName = new StringBuffer();

    fileName.append(artifact.getArtifactId()).append("-").append(artifact.getBaseVersion());

    if (artifact.hasClassifier()) {
        fileName.append("-").append(artifact.getClassifier());
    }

    if (artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0) {
        fileName.append(".").append(artifactHandler.getExtension());
    }

    String relativePath = artifactRepositoryLayout.pathOf(artifact);
    String[] tokens = StringUtils.split(relativePath, "/");
    tokens[tokens.length - 1] = fileName.toString();

    StringBuffer path = new StringBuffer();

    for (int i = 0; i < tokens.length; ++i) {

        path.append(tokens[i]);
        if (i != tokens.length - 1) {
            path.append("/");
        }
    }

    return path.toString();

}

From source file:org.codehaus.mojo.appassembler.util.DependencyFactory.java

License:Open Source License

/**
 * Used by GenericDaemonGenerator./* w ww.  j  a v a2  s  . com*/
 */
public static Dependency create(Artifact artifact, ArtifactRepositoryLayout layout,
        String outputFileNameMapping) {
    Dependency dependency = new Dependency();
    dependency.setGroupId(artifact.getGroupId());
    dependency.setArtifactId(artifact.getArtifactId());
    dependency.setVersion(artifact.getVersion());
    dependency.setClassifier(artifact.getClassifier());

    String path = layout.pathOf(artifact);
    if (StringUtils.isNotEmpty(outputFileNameMapping)) {
        // Replace the file name part of the path with one that has been mapped
        File directory = new File(path).getParentFile();

        try {
            String fileName = MappingUtils.evaluateFileNameMapping(outputFileNameMapping, artifact);
            File file = new File(directory, fileName);
            // Always use forward slash as path separator, because that's what layout.pathOf( artifact ) uses
            path = file.getPath().replace('\\', '/');
        } catch (InterpolationException e) {
            // TODO Handle exceptions!
            // throw new MojoExecutionException("Unable to map file name.", e);
        }
    }
    dependency.setRelativePath(path);

    return dependency;
}

From source file:org.codehaus.mojo.osxappbundle.CreateApplicationBundleMojo.java

License:Apache License

/**
 * Copy all dependencies into the $JAVAROOT directory
 *
 * @param javaDirectory where to put jar files
 * @return A list of file names added/*from  w w w.ja va2  s  . c o m*/
 * @throws MojoExecutionException
 */
private List copyDependencies(File javaDirectory) throws MojoExecutionException {

    ArtifactRepositoryLayout layout = new DefaultRepositoryLayout();

    List list = new ArrayList();

    File repoDirectory = new File(javaDirectory, "repo");
    repoDirectory.mkdirs();

    // First, copy the project's own artifact
    File artifactFile = project.getArtifact().getFile();
    list.add(repoDirectory.getName() + "/" + layout.pathOf(project.getArtifact()));

    try {
        FileUtils.copyFile(artifactFile, new File(repoDirectory, layout.pathOf(project.getArtifact())));
    } catch (IOException e) {
        throw new MojoExecutionException(
                "Could not copy artifact file " + artifactFile + " to " + javaDirectory);
    }

    Set artifacts = project.getArtifacts();

    Iterator i = artifacts.iterator();

    while (i.hasNext()) {
        Artifact artifact = (Artifact) i.next();

        File file = artifact.getFile();
        File dest = new File(repoDirectory, layout.pathOf(artifact));

        getLog().debug("Adding " + file);

        try {
            FileUtils.copyFile(file, dest);
        } catch (IOException e) {
            throw new MojoExecutionException("Error copying file " + file + " into " + javaDirectory, e);
        }

        list.add(repoDirectory.getName() + "/" + layout.pathOf(artifact));
    }

    return list;
}