private List<String> getClasspathForScope( ProjectBuildingResult projectBuildingResult, String scope) throws DependencyResolutionRequiredException { MavenProject project = projectBuildingResult.getProject(); if ("compile".equalsIgnoreCase(scope)) { return project.getCompileClasspathElements(); } else if ("runtime".equalsIgnoreCase(scope)) { return project.getRuntimeClasspathElements(); } return project.getTestClasspathElements(); }
private File[] getClassPathFiles() { final List<File> files = new ArrayList<>(); List<?> classpathElements; try { classpathElements = project.getTestClasspathElements(); } catch (DependencyResolutionRequiredException e) { throw new RuntimeException(e.getMessage(), e); } for (final Object o : classpathElements) { if (o != null) { final File file = new File(o.toString()); if (file.canRead()) { files.add(file); } } } return files.toArray(new File[files.size()]); }
protected void generateDescriptor(String scope, File outputFile) throws MojoExecutionException { ExtractorConfiguration ec = new ExtractorConfiguration(); try { if (scope.equals(COMPILE_SCOPE)) { ec.classpath = mavenProject.getCompileClasspathElements(); ec.outputDirectory = new File(mavenProject.getBuild().getOutputDirectory()); ec.sourceDirectories = mavenProject.getCompileSourceRoots(); } else if (scope.equals(TEST_SCOPE)) { ec.classpath = mavenProject.getTestClasspathElements(); ec.outputDirectory = new File(mavenProject.getBuild().getTestOutputDirectory()); ec.sourceDirectories = mavenProject.getTestCompileSourceRoots(); } metadataGenerator.generateDescriptor(ec, outputFile); } catch (Exception e) { throw new MojoExecutionException("Error generating metadata: ", e); } }
@Override protected List getClasspathElements(MavenProject project) throws DependencyResolutionRequiredException { return project.getTestClasspathElements(); }
@Override public List<String> getClasspathElements(final MavenProject project) throws DependencyResolutionRequiredException { return project.getTestClasspathElements(); }