Example usage for org.apache.maven.project MavenProject getRuntimeDependencies

List of usage examples for org.apache.maven.project MavenProject getRuntimeDependencies

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getRuntimeDependencies.

Prototype

@Deprecated 
    public List<Dependency> getRuntimeDependencies() 

Source Link

Usage

From source file:org.novelang.maven.SourceAggregatorMojo.java

License:Open Source License

private static List<File> buildSourcePathList(final MavenProject project) throws MojoExecutionException {

    @SuppressWarnings({ "unchecked" })
    final List<Dependency> dependencies = project.getRuntimeDependencies();
    final ImmutableList.Builder<File> sourcePathListBuilder = ImmutableList.builder();

    final File parentRoot = findParentRoot(project);

    for (final Dependency dependency : dependencies) {
        final Matcher matcher = DIRECTORY_NAME_GRABBER_PATTERN.matcher(dependency.getArtifactId());
        final String moduleDirectory;
        if (matcher.find()) {
            if (matcher.groupCount() == 1) {
                moduleDirectory = matcher.group(1);
                final String moduleFileName = parentRoot.getAbsolutePath()
                        + MODULES_RELATIVE_PATH_FROM_ROOT_PROJECT + moduleDirectory
                        + MAIN_JAVA_SOURCE_DIRECTORY;

                sourcePathListBuilder.add(new File(moduleFileName));
            } else {
                throw new MojoExecutionException(
                        "Couldn't apply pattern '" + DIRECTORY_NAME_GRABBER_PATTERN.pattern() + " to '"
                                + dependency.getArtifactId() + "'");
            }//from  w  w w . ja  va 2s. c o  m
        }
    }
    return sourcePathListBuilder.build();
}