public static Classpath emptyClasspath() { return new Classpath(); }
@Override public Classpath clone() { return new Classpath( unmodifiableElements ); } }
public Classpath addClassPathElementUrl( String path ) { if ( path == null ) { throw new IllegalArgumentException( "Null is not a valid class path element url." ); } return !unmodifiableElements.contains( path ) ? new Classpath( this, path ) : this; }
Classpath getClasspath( String prefix ) { List<String> elements = getStringList( prefix ); return new Classpath( elements ); }
public static Classpath setCachedClasspath( @Nonnull String key, @Nonnull Set<Artifact> artifacts ) { Collection<String> files = new ArrayList<>(); for ( Artifact artifact : artifacts ) { files.add( artifact.getFile().getAbsolutePath() ); } Classpath classpath = new Classpath( files ); setCachedClasspath( key, classpath ); return classpath; } }
public static Classpath setCachedClasspath( @Nonnull String key, @Nonnull Set<Artifact> artifacts ) { Collection<String> files = new ArrayList<String>(); for ( Artifact artifact : artifacts ) { files.add( artifact.getFile().getAbsolutePath() ); } Classpath classpath = new Classpath( files ); setCachedClasspath( key, classpath ); return classpath; } }
public static Classpath join( Classpath firstClasspath, Classpath secondClasspath ) { LinkedHashSet<String> accumulated = new LinkedHashSet<>(); if ( firstClasspath != null ) { firstClasspath.addTo( accumulated ); } if ( secondClasspath != null ) { secondClasspath.addTo( accumulated ); } return new Classpath( accumulated ); }
Classpath toClasspath() { List<String> classpath = new ArrayList<>(); classpath.add( testClassesDirectory.getAbsolutePath() ); classpath.add( classesDirectory.getAbsolutePath() ); for ( Artifact artifact : artifacts ) { if ( artifact.getArtifactHandler().isAddedToClasspath() ) { File file = artifact.getFile(); if ( file != null ) { classpath.add( file.getAbsolutePath() ); } } } if ( additionalClasspathElements != null ) { for ( String additionalClasspathElement : additionalClasspathElements ) { if ( additionalClasspathElement != null ) { addAll( classpath, split( additionalClasspathElement, "," ) ); } } } return new Classpath( classpath ); } }
Classpath toClasspath() { List<String> classpath = new ArrayList<String>(); classpath.add( testClassesDirectory.getAbsolutePath() ); classpath.add( classesDirectory.getAbsolutePath() ); for ( Artifact artifact : artifacts ) { if ( artifact.getArtifactHandler().isAddedToClasspath() ) { File file = artifact.getFile(); if ( file != null ) { classpath.add( file.getAbsolutePath() ); } } } if ( additionalClasspathElements != null ) { for ( String additionalClasspathElement : additionalClasspathElements ) { if ( additionalClasspathElement != null ) { addAll( classpath, split( additionalClasspathElement, "," ) ); } } } return new Classpath( classpath ); } }
private Classpath getArtifactClasspath( Artifact surefireArtifact ) { Classpath existing = ClasspathCache.getCachedClassPath( surefireArtifact.getArtifactId() ); if ( existing == null ) { List<String> items = new ArrayList<>(); for ( Artifact artifact : dependencyResolver.resolveArtifact( surefireArtifact ).getArtifacts() ) { getConsoleLogger().debug( "Adding to " + getPluginName() + " booter test classpath: " + artifact.getFile().getAbsolutePath() + " Scope: " + artifact.getScope() ); items.add( artifact.getFile().getAbsolutePath() ); } existing = new Classpath( items ); ClasspathCache.setCachedClasspath( surefireArtifact.getArtifactId(), existing ); } return existing; }
private Classpath getArtifactClasspath( Artifact surefireArtifact ) { Classpath existing = ClasspathCache.getCachedClassPath( surefireArtifact.getArtifactId() ); if ( existing == null ) { ArtifactResolutionResult result = resolveArtifact( null, surefireArtifact ); List<String> items = new ArrayList<String>(); for ( Object o : result.getArtifacts() ) { Artifact artifact = (Artifact) o; getConsoleLogger().debug( "Adding to " + getPluginName() + " booter test classpath: " + artifact.getFile().getAbsolutePath() + " Scope: " + artifact.getScope() ); items.add( artifact.getFile().getAbsolutePath() ); } existing = new Classpath( items ); ClasspathCache.setCachedClasspath( surefireArtifact.getArtifactId(), existing ); } return existing; }
public ClassLoader createMergedClassLoader() throws SurefireExecutionException { Collection<String> modulePath = getModularClasspath().getModulePath(); return createMergedClassLoader( join( getInprocTestClasspath(), new Classpath( modulePath ) ) ); }