本文整理汇总了Java中org.codehaus.plexus.util.DirectoryScanner.setCaseSensitive方法的典型用法代码示例。如果您正苦于以下问题:Java DirectoryScanner.setCaseSensitive方法的具体用法?Java DirectoryScanner.setCaseSensitive怎么用?Java DirectoryScanner.setCaseSensitive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.setCaseSensitive方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchDir
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private Stream<File> searchDir(File dir, boolean warnOnBadDir) {
if (dir == null || !dir.exists() || !dir.isDirectory()) {
if (warnOnBadDir && dir != null) {
getLog().warn("Directory does not exist or is not a directory: " + dir);
}
return Stream.empty();
}
getLog().debug("Adding directory " + dir);
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(dir);
ds.setIncludes(includes != null && includes.length > 0 ? includes : DEFAULT_INCLUDES);
ds.setExcludes(excludes);
ds.addDefaultExcludes();
ds.setCaseSensitive(false);
ds.setFollowSymlinks(false);
ds.scan();
return Stream.of(ds.getIncludedFiles()).map(filename -> new File(dir, filename)).parallel();
}
示例2: getDirectoryFileNames
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Retrieves a list of file names that are in the given directory, possibly filtered by the list of include
* patterns or exclude patterns
*
* @param baseDirectory directory to retrieve file names from
* @param includes list of patterns to match against for file names to include, can include Ant patterns
* @param excludes list of patterns to match for excluded file names, can include Ant patterns
* @return list of file names within the directory that match all given patterns
*/
public static List<String> getDirectoryFileNames(File baseDirectory, String[] includes, String[] excludes) {
List<String> files = new ArrayList<String>();
DirectoryScanner scanner = new DirectoryScanner();
if (includes != null) {
scanner.setIncludes(includes);
}
if (excludes != null) {
scanner.setExcludes(excludes);
}
scanner.setCaseSensitive(false);
scanner.addDefaultExcludes();
scanner.setBasedir(baseDirectory);
scanner.scan();
for (String includedFilename : scanner.getIncludedFiles()) {
files.add(includedFilename);
}
return files;
}
示例3: getClasses
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public List<String> getClasses() {
DirectoryScanner classScanner = new DirectoryScanner();
String baseDir = getClassDir();
List<String> ret = new ArrayList<>();
if(!new File(baseDir).exists()) {
return ret;
}
classScanner.setBasedir(baseDir);
classScanner.setCaseSensitive(true);
classScanner.setIncludes(new String[]{"**/*class"});
classScanner.setExcludes(new String[]{"**/*$*.class"});
classScanner.scan();
for(String s: classScanner.getIncludedFiles()){
ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
}
return ret;
}
示例4: getTestClasses
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public List<String> getTestClasses() {
List<String> ret = new ArrayList<>();
DirectoryScanner scanner = new DirectoryScanner();
String baseDir = getTestclassDir();
if(!new File(baseDir).exists()) {
return ret;
}
scanner.setBasedir(baseDir);
scanner.setCaseSensitive(true);
scanner.scan();
for(String s: scanner.getIncludedFiles()){
ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
}
return ret;
}
示例5: getTestClasses
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public List<String> getTestClasses(){
List<String> ret = new ArrayList<>();
DirectoryScanner scanner = new DirectoryScanner();
String baseDir = this.targetDir+"/target/classes";
if(!new File(baseDir).exists()) {
return ret;
}
makeFilter(scanner);
final String testClassPath = new PathBuilder().path(targetDir).path("target").path("test-classes").buildFilePath(); //MAVEN TEST CLASS FOLDER
if(!new File(testClassPath).exists()) {
return ret;
}
scanner.setBasedir(testClassPath);
scanner.setCaseSensitive(true);
scanner.scan();
for(String s: scanner.getIncludedFiles()){
ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
}
return ret;
}
示例6: getClasses
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public List<String> getClasses(){
DirectoryScanner classScanner = new DirectoryScanner();
String baseDir = new PathBuilder().path(targetDir).path("target").path("classes").buildFilePath();
List<String> ret = new ArrayList<>();
if(!new File(baseDir).exists()) {
return ret;
}
classScanner.setBasedir(baseDir);
classScanner.setCaseSensitive(true);
classScanner.setIncludes(new String[]{"**/*class"});
classScanner.setExcludes(new String[]{"**/*$*.class"});
classScanner.scan();
for(String s: classScanner.getIncludedFiles()){
ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
}
return ret;
}
示例7: getDirectoryContents
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Retrieves a list of files and directories that are in the given directory, possibly filtered by the
* list of include patterns or exclude patterns
*
* @param baseDirectory directory to retrieve files and directories from
* @param includes list of patterns to match against for files to include, can include Ant patterns
* @param excludes list of patterns to match for excluded files, can include Ant patterns
* @return list of files within the directory that match all given patterns
*/
public static List<String> getDirectoryContents(File baseDirectory, String[] includes, String[] excludes) {
List<String> contents = new ArrayList<String>();
DirectoryScanner scanner = new DirectoryScanner();
if (includes != null) {
scanner.setIncludes(includes);
}
if (excludes != null) {
scanner.setExcludes(excludes);
}
scanner.setCaseSensitive(false);
scanner.addDefaultExcludes();
scanner.setBasedir(baseDirectory);
scanner.scan();
for (String includedDirectory : scanner.getIncludedDirectories()) {
contents.add(includedDirectory);
}
for (String includedFilename : scanner.getIncludedFiles()) {
contents.add(includedFilename);
}
return contents;
}
示例8: scanDirectory
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Method to scan given directory for include and exclude patterns.
*
* @param jarExtractedDir - Patch to check for given include/exclude pattern
* @param includes - Include pattern array
* @param excludes - Exclude class pattern array
* @return - Included files
* @throws IOException - Throws if given directory patch cannot be found.
*/
public static String[] scanDirectory(String jarExtractedDir, String[] includes,
String[] excludes) throws IOException {
DirectoryScanner ds = new DirectoryScanner();
ds.setIncludes(includes);
ds.setExcludes(excludes);
ds.setBasedir(new File(jarExtractedDir));
ds.setCaseSensitive(true);
ds.scan();
return ds.getIncludedFiles();
}
示例9: findScripts
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public Collection<String> findScripts() {
getLogger().info("Looking for scripts in " + baseDir + "...");
DirectoryScanner scanner = new DirectoryScanner();
scanner.setCaseSensitive(false);
scanner.setBasedir(baseDir);
if (specific != null && !specific.isEmpty()) {
List<String> temp = new ArrayList<String>();
if (specific.endsWith(".js") || specific.endsWith(".coffee")) {
temp.add("**/"+specific);
} else {
temp.add("**/"+specific+".js");
temp.add("**/"+specific+".coffee");
}
scanner.setIncludes(temp.toArray(new String[temp.size()]));
} else {
scanner.setIncludes(includes.toArray(new String[includes.size()]));
scanner.setExcludes(excludes.toArray(new String[excludes.size()]));
}
scanner.scan();
List<String> result = asList(scanner.getIncludedFiles());
if (result.isEmpty()) {
getLogger().warn("No files found in directory " + baseDir + " matching criterias");
}
return result;
}
示例10: findIncludes
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
public List<String> findIncludes() {
getLogger().info("Looking for includes in " + baseDir + "...");
DirectoryScanner scanner = new DirectoryScanner();
scanner.setCaseSensitive(false);
scanner.setBasedir(baseDir);
scanner.setIncludes(patterns.toArray(new String[patterns.size()]));
scanner.scan();
return asList(scanner.getIncludedFiles());
}
示例11: findFilesMatching
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private Stream<String> findFilesMatching(String filePattern) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes(new String[]{filePattern});
scanner.setBasedir(basedir);
scanner.setCaseSensitive(false);
scanner.scan();
return stream(scanner.getIncludedFiles());
}
示例12: getProjectSources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Generate a list of source files in the project directory and sub-directories
* @param vcProject the parsed project
* @param includeHeaders set to true to include header files (*.h and *.hpp)
* @param excludes a List of pathname patterns to exclude from results
* @return a list of abstract paths representing each source file
*/
protected List<File> getProjectSources( VCProject vcProject, boolean includeHeaders, List<String> excludes )
throws MojoExecutionException
{
final DirectoryScanner directoryScanner = new DirectoryScanner();
List<String> sourceFilePatterns = new ArrayList<String>();
String relProjectDir = calculateProjectRelativeDirectory( vcProject );
sourceFilePatterns.add( relProjectDir + "**\\*.c" );
sourceFilePatterns.add( relProjectDir + "**\\*.cpp" );
if ( includeHeaders )
{
sourceFilePatterns.add( relProjectDir + "**\\*.h" );
sourceFilePatterns.add( relProjectDir + "**\\*.hpp" );
}
//Make sure we use case-insensitive matches as this plugin runs on a Windows platform
directoryScanner.setCaseSensitive( false );
directoryScanner.setIncludes( sourceFilePatterns.toArray( new String[0] ) );
directoryScanner.setExcludes( excludes.toArray( new String[excludes.size()] ) );
directoryScanner.setBasedir( vcProject.getBaseDirectory() );
directoryScanner.scan();
List<File> sourceFiles = new ArrayList<File>();
for ( String fileName : directoryScanner.getIncludedFiles() )
{
sourceFiles.add( new File( vcProject.getBaseDirectory(), fileName ) );
}
return sourceFiles;
}
示例13: run
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Prepare sources");
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
boolean atLeastOneCopied = false;
if (!FALSE.equals(build.getUseTemporaryGopath())) {
final Path gopath = build.getFirstGopath();
progress.progress("Prepare GOPATH " + gopath + "...");
LOGGER.info("Prepare GOPATH ({})...", gopath);
final Path projectBasedir = settings.getProjectBasedir();
final Path packagePath = settings.packagePathFor(gopath);
final Path dependencyCachePath = getDependencies().getDependencyCache();
prepareDependencyCacheIfNeeded(packagePath, dependencyCachePath);
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(projectBasedir.toFile());
scanner.setIncludes(build.getIncludes());
scanner.setExcludes(build.getExcludes());
scanner.setCaseSensitive(true);
scanner.scan();
for (final String file : scanner.getIncludedFiles()) {
final Path sourceFile = projectBasedir.resolve(file);
final Path targetFile = packagePath.resolve(file);
if (!sourceFile.equals(dependencyCachePath)) {
if (!exists(targetFile)
|| size(sourceFile) != size(targetFile)
|| !getLastModifiedTime(sourceFile).equals(getLastModifiedTime(targetFile))) {
atLeastOneCopied = true;
progress.progress("Prepare source file: " + file + "...");
LOGGER.debug("* {}", file);
ensureParentOf(targetFile);
try (final InputStream is = newInputStream(sourceFile)) {
try (final OutputStream os = newOutputStream(targetFile)) {
IOUtils.copy(is, os);
}
}
setLastModifiedTime(targetFile, getLastModifiedTime(sourceFile));
}
}
}
if (!atLeastOneCopied) {
getState().setOutcome(UP_TO_DATE);
}
} else {
getState().setOutcome(SKIPPED);
}
progress.completed();
}
示例14: scan
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Scans the file-trees under the specified directories for files matching
* the specified patterns.
*/
public static Sources scan(
Log log, DirectoryScannerSpec spec) throws IOException {
String[] includesArray = spec.includes.toArray(new String[0]);
String[] excludesArray = spec.excludes.toArray(new String[0]);
Map<File, Source> found = Maps.newLinkedHashMap();
for (TypedFile root : spec.roots) {
if (!root.f.exists()) {
log.debug("Skipping scan of non-extant root directory " + root.f);
continue;
}
File canonRoot = root.f.getCanonicalFile();
TypedFile typedCanonRoot = new TypedFile(canonRoot, root.ps);
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(canonRoot);
scanner.setIncludes(includesArray);
scanner.setExcludes(excludesArray);
scanner.addDefaultExcludes();
scanner.setCaseSensitive(true); // WTF MacOS
scanner.setFollowSymlinks(true);
scanner.scan();
for (String relPath : scanner.getIncludedFiles()) {
relPath = Files.simplifyPath(relPath);
File file = new File(
FilenameUtils.concat(canonRoot.getPath(), relPath));
File canonFile = file.getCanonicalFile();
TypedFile sourceRoot = typedCanonRoot;
Source prev = found.get(canonFile);
if (prev != null) {
EnumSet<SourceFileProperty> combinedProps =
EnumSet.noneOf(SourceFileProperty.class);
combinedProps.addAll(sourceRoot.ps);
combinedProps.retainAll(prev.root.ps);
// We AND these together because of the following case-based
// analysis over the properties.
// TEST_ONLY -- if either file is not test only, then the combined is
// not test only.
// LOAD_AS_NEEDED -- if either file is always loaded, the combined is
// always needed.
sourceRoot = new TypedFile(sourceRoot.f, combinedProps);
}
File relFile = new File(relPath);
Source source = new Source(canonFile, sourceRoot, relFile);
found.put(canonFile, source);
}
}
return new Sources(found.values());
}