List<String> classpathElements = project.getCompileClasspathElements();
@SuppressWarnings("unchecked") protected final ClassLoader getClassLoader() throws MojoExecutionException, DependencyResolutionRequiredException { final MavenProject project = project(); final List<String> classpathElements = new ArrayList<>(); classpathElements.addAll(project.getCompileClasspathElements()); classpathElements.addAll(project.getRuntimeClasspathElements()); classpathElements.add(project.getBuild().getOutputDirectory()); final List<URL> projectClasspathList = new ArrayList<>(); for (final String element : classpathElements) { try { projectClasspathList.add(new File(element).toURI().toURL()); } catch (final MalformedURLException ex) { throw new MojoExecutionException( element + " is an invalid classpath element", ex ); } } return new URLClassLoader( projectClasspathList.toArray(new URL[projectClasspathList.size()]), Thread.currentThread().getContextClassLoader() ); }
/** * @return ClassLoader containing the compile paths. */ private ClassLoader getCompileClassLoader() { try { final List<String> runtimeClasspathElements = project.getCompileClasspathElements(); final ClassLoaderFactory factory = new ClassLoaderFactory( runtimeClasspathElements ); return factory.create(); } catch ( DependencyResolutionRequiredException e ) { throw new IllegalStateException( "Mojo should have resolved dependencies", e ); } }
String [] roots = project.getCompileClasspathElements().toArray(new String[0]);
protected String findMainClass(MavenProject project) { List<String> mainClasses = U.list(); try { for (String path : project.getCompileClasspathElements()) { if (new File(path).isDirectory()) { getLog().info("Scanning classpath directory: " + path); scanForMainClass(path, mainClasses); } else if (!path.endsWith(".jar")) { getLog().warn("Ignoring classpath entry: " + path); } } } catch (Exception e) { throw U.rte(e); } switch (mainClasses.size()) { case 0: getLog().warn("Couldn't find the main class!"); return null; case 1: return U.first(mainClasses); default: getLog().warn("Found multiple main classes, trying to pick the right one: " + mainClasses); return pickMainClass(mainClasses, project); } }
private ClassLoader getProjectClassLoader() throws Exception { List<String> cp = project.getCompileClasspathElements(); URL[] urls = new URL[cp.size()]; for (int i = 0; i < cp.size(); i++) { urls[i] = new File(cp.get(i)).toURI().toURL(); } return new URLClassLoader(urls, this.getClass().getClassLoader()); }
List l = project.getCompileClasspathElements(); for ( Iterator i = l.iterator(); i.hasNext(); ) { String element = (String) i.next();
@Override protected List<String> getClasspathElements() throws DependencyResolutionRequiredException { return project.getCompileClasspathElements(); } }
public List<String> getCompileClasspathElements() throws DependencyResolutionRequiredException { return wrapped.getCompileClasspathElements(); }
@SuppressWarnings("unchecked") private static List<String> compileClassPathElements(MavenProject project) throws DependencyResolutionRequiredException { return newArrayList(project.getCompileClasspathElements()); } }
public static Optional<List<String>> getCompileClasspathElementsIfRequested(MavenProject project, boolean useProjectClasspath) throws MojoExecutionException { if (!useProjectClasspath) { return Optional.empty(); } try { return Optional.of(project.getCompileClasspathElements()); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Cannot extra compile class path elements", e); } } }
protected final List getClassPaths() throws MojoExecutionException { if (this.classPaths.isEmpty()) { try { this.classPaths.addAll(this.mojo.getMavenProject().getCompileClasspathElements()); } catch (final DependencyResolutionRequiredException e) { throw new MojoExecutionException("JAVAH, cannot get classpath", e); } } return this.classPaths; }
@SuppressWarnings("unchecked") @Override protected List<String> getClasspathElements() throws Exception { return TychoUtilities.addOsgiClasspathElements(project, project.getCompileClasspathElements()); }
public static URLClassLoader getCompileClassLoader(MavenProject project) { try { List<String> classpathElements = project.getCompileClasspathElements(); return createClassLoader(classpathElements, project.getBuild().getOutputDirectory()); } catch (DependencyResolutionRequiredException e) { throw new IllegalArgumentException("Cannot resolve artifact from compile classpath",e); } }
/** * {@inheritDoc} */ @Override protected List<String> getClasspath() throws MojoExecutionException { try { return (List<String>) getProject().getCompileClasspathElements(); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Could not retrieve Compile classpath.", e); } }
/** * {@inheritDoc} */ @Override protected List<String> getClasspath() throws MojoExecutionException { try { return (List<String>) getProject().getCompileClasspathElements(); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Could not retrieve Compile classpath.", e); } }
public static URLClassLoader getUrlClassLoader(MavenProject project) throws MojoFailureException { try { // collect compile classpath classes URL[] urls = project.getCompileClasspathElements().stream() .map(File::new) .filter(File::exists) .map(new FileToUrl()).toArray(URL[]::new); return new URLClassLoader(urls, currentThread().getContextClassLoader()); } catch (DependencyResolutionRequiredException e) { throw new MojoFailureException(e.getMessage(), e); } }
private Set<URL> collectClasspathUrls(MavenProject project) throws DependencyResolutionRequiredException, MalformedURLException { Set<String> classpathElements = new HashSet<>(); classpathElements.addAll(project.getRuntimeClasspathElements()); classpathElements.addAll(project.getCompileClasspathElements()); return collectClasspathUrls(classpathElements); }
@Override protected List<String> getClasspathElements() { try { return getMavenProject().getCompileClasspathElements(); } catch (DependencyResolutionRequiredException e) { getLog().error(e); } return null; } }
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(); }