当前位置: 首页>>代码示例>>Java>>正文


Java Scanner类代码示例

本文整理汇总了Java中org.codehaus.plexus.util.Scanner的典型用法代码示例。如果您正苦于以下问题:Java Scanner类的具体用法?Java Scanner怎么用?Java Scanner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Scanner类属于org.codehaus.plexus.util包,在下文中一共展示了Scanner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scan

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
/**
 * Scans using the given plexus scanner.
 * This is like {@link Sources#scan} but uses a provided scanner like one of
 * the special purpose ones provided by
 * {@link org.sonatype.plexus.build.incremental.BuildContext}.
 */
public ImmutableList<Source> scan(
    Scanner s, Iterable<SourceFileProperty> ps)
throws IOException {
  s.setIncludes(includes.toArray(EMPTY_STRING_ARRAY));
  s.setExcludes(excludes.toArray(EMPTY_STRING_ARRAY));
  s.scan();
  String[] files = s.getIncludedFiles();
  if (files == null) { return ImmutableList.of(); }

  TypedFile root = new TypedFile(s.getBasedir().getCanonicalFile(), ps);
  String prefix = root.f.getPath();
  if (prefix.isEmpty()) { prefix = "."; }
  if (!prefix.endsWith(File.separator)) {
    prefix += File.separator;
  }

  ImmutableList.Builder<Source> sources = ImmutableList.builder();
  for (String file : files) {
    sources.add(new Source(
        new File(prefix + file).getCanonicalFile(), root, new File(file)));
  }
  return sources.build();
}
 
开发者ID:mikesamuel,项目名称:closure-maven-plugin,代码行数:30,代码来源:DirectoryScannerSpec.java

示例2: getIncludedSources

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
protected Set<String> getIncludedSources()
        throws MojoExecutionException {
    Set<String> result = new HashSet<String>();
    if (getJavaSources() == null) {
        result = AjcHelper.getBuildFilesForSourceDirs(getSourceDirectories(), this.includes, this.excludes);
    } else {
        for (int scannerIndex = 0; scannerIndex < getJavaSources().length; scannerIndex++) {
            Scanner scanner = getJavaSources()[scannerIndex];
            if (scanner.getBasedir() == null) {
                getLog().info("Source without basedir, skipping it.");
            } else {
                scanner.scan();
                for (int fileIndex = 0; fileIndex < scanner.getIncludedFiles().length; fileIndex++) {
                    result.add(FileUtils.resolveFile(scanner.getBasedir(),
                            scanner.getIncludedFiles()[fileIndex]).getAbsolutePath());
                }
            }
        }
    }
    return result;
}
 
开发者ID:mojohaus,项目名称:aspectj-maven-plugin,代码行数:22,代码来源:AbstractAjcCompiler.java

示例3: getClasses

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private List<Class> getClasses(final String sourceRoot, final String[] includes, final Predicate<Class> predicate)
    throws Exception {

    final Scanner scanner = buildContext.newScanner(new File(sourceRoot));
    scanner.setIncludes(includes);
    scanner.scan();

    String[] sources = scanner.getIncludedFiles();
    if (sources.length == 0) {
        return new ArrayList<>();
    }

    List<Class> result = new ArrayList<>();
    for (String source : sources) {
        String className = AnalyzeHelper.getTopLevelClassName(source);

        Class clazz = Class.forName(className, false, classLoader);

        if (predicate.apply(clazz)) {
            result.add(clazz);
        }
    }

    return result;
}
 
开发者ID:Lauriapple1,项目名称:security-gwt,代码行数:26,代码来源:RpcSecurityAnalyzeMojo.java

示例4: isRebuildRequired

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private boolean isRebuildRequired() {
	if (ctx.isIncremental()) {
		if ((grammarFile != null && ctx.hasDelta(grammarFile)) 
				|| ctx.hasDelta(templateFile) 
				|| (inputFile != null && inputFile.isFile() && ctx.hasDelta(inputFile))) {
			return true;
		} else if (inputFile != null && inputFile.isDirectory()) {
			Scanner scanner = ctx.newScanner(inputFile, true);
			info("Scanning...");
			scanner.scan();
			if (scanner.getIncludedFiles() != null) {
				for (String includedFile : scanner.getIncludedFiles()) {
					if (ctx.hasDelta(new File(scanner.getBasedir(), includedFile))) {
						info("Changes detected.  Rebuilding.");
						return true;
					}
				}
			}
		}
		info("Nothing has changed.");
		return false;
	} else {
		info("Full rebuild requested.");
		return true;
	}
}
 
开发者ID:danishdynamite,项目名称:templates4j,代码行数:27,代码来源:Templates4jMojo.java

示例5: shouldExecute

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
static boolean shouldExecute(BuildContext buildContext, List<File> triggerfiles, File srcdir) {

    // If there is no buildContext, or this is not an incremental build, always execute.
    if (buildContext == null || !buildContext.isIncremental()) {
      return true;
    }

    if (triggerfiles != null) {
      for (File triggerfile : triggerfiles) {
        if (buildContext.hasDelta(triggerfile)) {
          return true;
        }
      }
    }

    if (srcdir == null) {
      return true;
    }

    // Check for changes in the srcdir
    Scanner scanner = buildContext.newScanner(srcdir);
    scanner.scan();
    String[] includedFiles = scanner.getIncludedFiles();
    return (includedFiles != null && includedFiles.length > 0);
  }
 
开发者ID:eirslett,项目名称:frontend-maven-plugin,代码行数:26,代码来源:MojoUtils.java

示例6: execute

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
@Override
public void execute()
    throws MojoExecutionException, MojoFailureException
{
    mavenProject.addCompileSourceRoot( outputDirectory.getAbsolutePath() );

    Scanner scanner = buildContext.newScanner( schemaDirectory );
    scanner.scan();

    if ( scanner.getIncludedFiles().length < 1 )
    {
        return;
    }

    if ( handleNativeDependency )
    {
        doHandleNativesDependency();
    }

    nativesManager.registerAllDescriptors();

    workDirectory.mkdirs();

    NativesInfo currentNativesInfo = nativesManager.getNativesInfoForCurrentPlatform();

    CapnpCompiler compiler =
        CapnpCompiler.builder()
            .setOutputDirectory( outputDirectory )
            .setSchemaDirectory( schemaDirectory )
            .setWorkDirectory( workDirectory )
            .setCapnpFile( copyResource( currentNativesInfo.getCapnpUrl(), workDirectory ) )
            .setCapnpcJavaFile( copyResource( currentNativesInfo.getCapnpcJavaUrl(), workDirectory ) )
            .setCapnpJavaSchemaFile( copyResource( currentNativesInfo.getCapnpJavaSchemaUrl(), workDirectory ) )
            .addSchemas( getSchemas() )
            .addImportDirectories( getImportDirectories() )
            .setVerbose( verbose )
            .build();

    compiler.compile();
}
 
开发者ID:expretio,项目名称:capnp-maven-plugin,代码行数:41,代码来源:CapnProtoMojo.java

示例7: scanAndGeneratePages

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private void scanAndGeneratePages(File sourceRoot) throws Exception
{
	if (getLog().isDebugEnabled())
	{
		getLog().debug("Scanning source folder: "+sourceRoot.getCanonicalPath());
	}

	
	Scanner scanner = getScanner(sourceRoot);
	scanner.setIncludes(new String[] { "**/*.crux.xml" });
	scanner.scan();
	String[] sources = scanner.getIncludedFiles();
	if (sources.length == 0)
	{
		return;
	}
	for (String source : sources)
	{
		File sourceFile = new File(sourceRoot, source);
		String viewId = getViewId(source);
		if (!StringUtils.isEmpty(viewId))
		{
			File targetFile = getTargetFile(viewId);
			if (isUptodate(targetFile, sourceFile))
			{
				getLog().debug(targetFile.getAbsolutePath() + " is up to date. Generation skipped");
				continue;
			}
			
			getLog().info("Generating HTML page for file " + source);
			targetFile.getParentFile().mkdirs();
			generateHTMLPage(viewId, sourceFile, targetFile);
		}
	}
}
 
开发者ID:CruxFramework,项目名称:crux-maven-plugin,代码行数:36,代码来源:PageResources.java

示例8: execute

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
/**
 * Performs the conversion.
 *
 * @throws MojoExecutionException
 *             thrown when there is a problem executing Mjo.
 */
@Override
public void execute() throws MojoExecutionException {

    destDir.mkdirs();
    if (fontFileSets == null) {
        final FileSet defaultFontFileSet = new FileSet();
        defaultFontFileSet.setDirectory(new File(project.getBasedir(), "src/main/ttf").getPath());
        defaultFontFileSet.addInclude("**/*.ttf");
        fontFileSets = Collections.singletonList(defaultFontFileSet);
    }
    for (final FileSet fileSet : fontFileSets) {
        final String directory = fileSet.getDirectory();
        final File baseDirectory = new File(directory); // NOPMD
        if (!baseDirectory.isDirectory()) { // NOPMD
            getLog().warn(format(R.getString("missingdir"), directory));
            continue;
        }
        final Scanner scanner = buildContext.newScanner(baseDirectory);
        scanner.setIncludes(fileSet.getIncludes().toArray(new String[0])); // NOPMD
        scanner.setExcludes(fileSet.getExcludes().toArray(new String[0])); // NOPMD
        scanner.scan();
        for (final String includedFile : scanner.getIncludedFiles()) {

            final File inputFile = new File(baseDirectory, // NOPMD
                    includedFile);
            final String basename = includedFile.substring(0, includedFile.lastIndexOf('.'));
            final File svgFile = new File(destDir, basename + ".svg"); // NOPMD
            try {
                final PrintStream ps = new PrintStream(// NOPMD
                        buildContext.newFileOutputStream(svgFile));
                SvgFontUtil.writeFontAsSvg(ps, Font.create(inputFile.toString()), basename);
                ps.close();
            } catch (final Exception e) {
                throw new MojoExecutionException(String.format(R.getString("failedtorender"), inputFile), e);
            }
        }
    }

}
 
开发者ID:trajano,项目名称:batik-maven-plugin,代码行数:46,代码来源:FontConverterMojo.java

示例9: compile

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
protected void compile() throws IOException {
    File sourceDirectory = getSourcesDirectory();
    File outputDirectory = getOutputDirectory();

    if (!outputDirectory.exists()) {
        outputDirectory.mkdirs();
    }

    Scanner fileScanner = context.newScanner(sourceDirectory, true);
    fileScanner.setIncludes(includes);
    fileScanner.setExcludes(excludes);
    fileScanner.scan();
    File basedir = fileScanner.getBasedir();

    List<File> changedFiles = new ArrayList<File>();
    for (String fileName : fileScanner.getIncludedFiles()) {
        File file = new File(basedir, fileName);
        changedFiles.add(file);
        context.removeMessages(file);
    }
    if (!changedFiles.isEmpty()) {
        try {
            File[] schemaFile = changedFiles.toArray(new File[changedFiles.size()]);
            GoraCompiler.compileSchema(schemaFile, outputDirectory);
        } catch (SchemaParseException e) {
            if (e.getCause() != null && e.getCause() instanceof JsonParseException) {
                attachErrorMessage((JsonParseException) e.getCause());
            } else {
                throw e;
            }
        }
    }
    context.refresh(outputDirectory);
}
 
开发者ID:dobromyslov,项目名称:gora-maven-plugin,代码行数:35,代码来源:AbstractGoraMojo.java

示例10: scanDirectoryForFiles

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
/**
 * Scans given directory for files satisfying given inclusion/exclusion
 * patterns.
 * 
 * @param directory
 *            Directory to scan.
 * @param includes
 *            inclusion pattern.
 * @param excludes
 *            exclusion pattern.
 * @param defaultExcludes
 *            default exclusion flag.
 * @return Files from the given directory which satisfy given patterns. The
 *         files are {@link File#getCanonicalFile() canonical}.
 */
public static List<File> scanDirectoryForFiles(BuildContext buildContext,
		final File directory, final String[] includes,
		final String[] excludes, boolean defaultExcludes)
		throws IOException {
	if (!directory.exists()) {
		return Collections.emptyList();
	}
	final Scanner scanner;

	if (buildContext != null) {
		scanner = buildContext.newScanner(directory, true);
	} else {
		final DirectoryScanner directoryScanner = new DirectoryScanner();
		directoryScanner.setBasedir(directory.getAbsoluteFile());
		scanner = directoryScanner;
	}
	scanner.setIncludes(includes);
	scanner.setExcludes(excludes);
	if (defaultExcludes) {
		scanner.addDefaultExcludes();
	}

	scanner.scan();

	final List<File> files = new ArrayList<File>();
	for (final String name : scanner.getIncludedFiles()) {
		files.add(new File(directory, name).getCanonicalFile());
	}

	return files;
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:47,代码来源:IOUtils.java

示例11: compile

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
protected void compile() throws IOException {
  File sourceDirectory = getSourcesDirectory();
  File outputDirectory = getOutputDirectory();

  if (!outputDirectory.exists()) {
    outputDirectory.mkdirs();
  }

  Scanner fileScanner = context.newScanner(sourceDirectory, true);
  fileScanner.setIncludes(includes);
  fileScanner.setExcludes(excludes);
  fileScanner.scan();
  File basedir = fileScanner.getBasedir();

  List<File> changedFiles = new ArrayList<File>();
  for (String fileName : fileScanner.getIncludedFiles()) {
    File file = new File(basedir, fileName);
    changedFiles.add(file);
    context.removeMessages(file);
  }
  if (!changedFiles.isEmpty()) {
    try {
      File[] schemaFile = changedFiles.toArray(new File[changedFiles.size()]);
      GoraCompiler.compileSchema(schemaFile, outputDirectory);
    } catch (SchemaParseException e) {
      if (e.getCause() != null && e.getCause() instanceof JsonParseException) {
        attachErrorMessage((JsonParseException) e.getCause());
      } else {
        throw e;
      }
    }
  }
  context.refresh(outputDirectory);
}
 
开发者ID:apache,项目名称:gora,代码行数:35,代码来源:AbstractGoraMojo.java

示例12: build

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
@Override
public Set<IProject> build( int kind, IProgressMonitor monitor )
    throws Exception
{
    IMaven maven = MavenPlugin.getMaven();
    BuildContext buildContext = getBuildContext();

    // check if any of the grammar files changed
    File source = maven.getMojoParameterValue(getSession(), getMojoExecution(), "schemaDirectory", File.class);
    Scanner ds = buildContext.newScanner( source ); // delta or full scanner
    ds.scan();
    String[] includedFiles = ds.getIncludedFiles();
    if (includedFiles == null || includedFiles.length <= 0 )
    {
        return null;
    }

    // execute mojo
    Set<IProject> result = super.build( kind, monitor );

    // tell m2e builder to refresh generated files
    File generated = maven.getMojoParameterValue(getSession(), getMojoExecution(), "dest", File.class);
    if (generated != null) {
        buildContext.refresh( generated );
    }

    return result;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:CastorBuildParticipant.java

示例13: findFiles

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private List<File> findFiles(final Scanner scanner) {
	final List<File> results = new ArrayList<File>();
	if (includes != null && includes.length > 0) {
		scanner.setIncludes(includes);
	}
	if (excludes != null && excludes.length > 0) {
		scanner.setExcludes(excludes);
	}
	scanner.addDefaultExcludes();
	scanner.scan();
	for (final String name : scanner.getIncludedFiles()) {
		results.add(new File(scanner.getBasedir(), name));
	}
	return results;
}
 
开发者ID:keithbranton,项目名称:angular-maven-plugin,代码行数:16,代码来源:Html2jsMojo.java

示例14: findFiles

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private List<File> findFiles(final Scanner scanner) {
	final List<File> results = new ArrayList<File>();
	scanner.setIncludes(modulesArray);
	scanner.scan();
	for (final String name : scanner.getIncludedFiles()) {
		results.add(new File(scanner.getBasedir(), name));
	}
	return results;
}
 
开发者ID:keithbranton,项目名称:angular-maven-plugin,代码行数:10,代码来源:JoinMojo.java

示例15: getSourceFiles

import org.codehaus.plexus.util.Scanner; //导入依赖的package包/类
private Set<File> getSourceFiles()
{
    if (source == null || !source.exists())
    {
        return new TreeSet<>();
    }

    String[] filters = ALL_JAVA_FILES_FILTER;
    if (includes != null && !includes.isEmpty())
    {
        filters = includes.toArray(new String[includes.size()]);
        for (int i = 0; i < filters.length; i++)
        {
            filters[i] = filters[i].replace('.', '/') + JAVA_FILE_FILTER;
        }
    }

    Set<File> files = new HashSet<File>();
    final Scanner scanner = buildContext.newScanner(source);
    scanner.setIncludes(filters);
    scanner.scan();

    String[] includedFiles = scanner.getIncludedFiles();
    if (includedFiles != null)
    {
        for (String includedFile : includedFiles)
        {
            files.add(new File(scanner.getBasedir(), includedFile));
        }
    }
    return files;
}
 
开发者ID:ethlo,项目名称:eclipselink-maven-plugin,代码行数:33,代码来源:EclipselinkModelGenMojo.java


注:本文中的org.codehaus.plexus.util.Scanner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。