com.dragome.commons.compiler.classpath.FolderClasspathEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dragome-js-commons Show documentation
Show all versions of dragome-js-commons Show documentation
Dragome SDK module: commons
The newest version!
package com.dragome.commons.compiler.classpath;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.jar.JarOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
import com.dragome.commons.compiler.CopyUtils;
public class FolderClasspathEntry implements ClasspathEntry
{
private File folder;
public FolderClasspathEntry(File folder)
{
this.folder= folder;
}
public ClasspathFile getClasspathFileOf(String relativeName)
{
File file= new File(folder, relativeName);
if (file.exists())
return new JavaFileClasspathFile(folder, relativeName);
else
return null;
}
public List getAllFilesNamesFiltering(ClasspathFileFilter classpathFilter)
{
List files= new ArrayList();
Collection listFiles= FileUtils.listFiles(folder, new WildcardFileFilter("*.class"), DirectoryFileFilter.DIRECTORY);
for (File file : listFiles)
{
String substring= file.toString().substring(folder.toString().length() + 1);
if (classpathFilter == null || classpathFilter.accept(file, folder))
{
files.add(substring.replace(".class", ""));
}
}
return files;
}
public static ClasspathEntry createFromPath(String classPathEntry)
{
return new FolderClasspathEntry(new File(classPathEntry));
}
public void copyFilesToJar(JarOutputStream jos)
{
try
{
CopyUtils.copyClassToJarFile(folder, jos);
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}
public String toString()
{
return folder.getAbsolutePath();
}
public String getName()
{
return folder.getAbsolutePath();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy