當前位置: 首頁>>代碼示例>>Java>>正文


Java BuildContext.newScanner方法代碼示例

本文整理匯總了Java中org.sonatype.plexus.build.incremental.BuildContext.newScanner方法的典型用法代碼示例。如果您正苦於以下問題:Java BuildContext.newScanner方法的具體用法?Java BuildContext.newScanner怎麽用?Java BuildContext.newScanner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.sonatype.plexus.build.incremental.BuildContext的用法示例。


在下文中一共展示了BuildContext.newScanner方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shouldExecute

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的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

示例2: scanDirectoryForFiles

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的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

示例3: build

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的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

示例4: build

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的package包/類
@Override
public Set<IProject> build(int kind, final IProgressMonitor monitor)
		throws Exception {

	final MojoExecution mojoExecution = getMojoExecution();

	if (mojoExecution == null) {
		return null;
	}

	final String phase = mojoExecution.getLifecyclePhase();
	log.debug("phase: {}", phase);

	final String goal = mojoExecution.getGoal();
	log.debug("goal: {}", goal);

	final IMaven maven = MavenPlugin.getMaven();
	final IMavenProjectFacade currentProject = getMavenProjectFacade();
	final BuildContext buildContext = getBuildContext();
	final IMavenProjectRegistry projectRegistry = MavenPlugin.getMavenProjectRegistry();

	ArtifactKey artifactKey = currentProject.getArtifactKey();
	String shortArtifactKey = artifactKey.getGroupId() + ":"
			+ artifactKey.getArtifactId() + ":" + artifactKey.getVersion();
	log.debug("artifact key: {}", shortArtifactKey);

	MavenProject mavenProject = currentProject.getMavenProject();
	// File basedir = mavenProject.getBasedir();
	// File inputPath = new File(basedir, "src");
	File inputPath = maven.getMojoParameterValue(mavenProject, mojoExecution, inputPathParam, File.class, monitor);
	
	String outputDirectoryPath = mavenProject.getBuild().getDirectory();
	File outputDirectory = new File(outputDirectoryPath);

	if (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind) {
		log.debug("scan resources {}", inputPath);
		Scanner ds = buildContext.newScanner(inputPath);
		ds.scan();
		String[] files = ds.getIncludedFiles();
		if (files == null || files.length <= 0) {
			log.debug("build check: no resource changes");
			log.debug("scan deleted resources {}", inputPath);
			ds = buildContext.newDeleteScanner(inputPath);
			ds.scan();
			files = ds.getIncludedFiles();
			if (files == null || files.length <= 0) {
				return null;
			} else {
				log.debug("build check: resources deleted");
			}
		} else {
			log.debug("build check: resources changed");
		}
	} else {
		log.debug("build check: full build");
	}

	final Set<IProject> result = super.build(kind, monitor);

	IProject project = currentProject.getProject();
	project.refreshLocal(IResource.DEPTH_INFINITE, monitor);

	if (outputDirectory != null && outputDirectory.exists()) {
		log.debug("refresh output directory: {}", outputDirectory);
		buildContext.refresh(outputDirectory);
	}

	return result;
}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:70,代碼來源:BuildParticipant.java

示例5: buildBundle

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的package包/類
/**
 * 
 * @param kind
 * @param monitor
 * @return
 * @throws Exception
 */
private Set<IProject> buildBundle(int kind, IProgressMonitor monitor) throws Exception {

	log.info("process \"bundle\" goal");

	final IMaven maven = MavenPlugin.getMaven();
	final IMavenProjectFacade currentProject = getMavenProjectFacade();
	final MavenProject mavenProject = currentProject.getMavenProject();
	final BuildContext buildContext = getBuildContext();
	final IMavenProjectRegistry projectRegistry = MavenPlugin.getMavenProjectRegistry();

	ArtifactKey artifactKey = currentProject.getArtifactKey();
	String shortArtifactKey = artifactKey.getGroupId() + ":" + artifactKey.getArtifactId() + ":" + artifactKey.getVersion();
	log.debug("artifact key: {}", shortArtifactKey);

	File basedir = mavenProject.getBasedir();
	File sourcesDirectory = new File(basedir, "src");

	File resourcesDirectory = maven.getMojoParameterValue(getSession(), getMojoExecution(), "resourcesDirectory", File.class);
	File outputDirectory = maven.getMojoParameterValue(getSession(), getMojoExecution(), "outputDirectory", File.class);
	File remoteResourcesDescriptor = new File(outputDirectory, "META-INF/maven/remote-resources.xml");

	String preprocessedFiles = null; // (String) buildContext.getValue("preprocessedFiles");

	if (remoteResourcesDescriptor.exists()) {
		if ((INCREMENTAL_BUILD == kind || AUTO_BUILD == kind) && preprocessedFiles == null) {
			log.debug("scan resources {}", resourcesDirectory);
			Scanner ds = buildContext.newScanner(resourcesDirectory);
			ds.scan();
			String[] files = ds.getIncludedFiles();
			if (files == null || files.length <= 0) {
				log.debug("build check: no resource changes");
				log.debug("scan deleted resources {}", resourcesDirectory);
				ds = buildContext.newDeleteScanner(resourcesDirectory);
				ds.scan();
				files = ds.getIncludedFiles();
				if (files == null || files.length <= 0) {
					return null;
				} else {
					log.debug("build check: resources deleted");
				}
			} else {
				log.debug("build check: resources changed");
			}
		} else {
			log.debug("build check: full build");
		}
	} else {
		log.debug("build check: remote resources descriptor does not exists");
	}

	final Set<IProject> result = super.build(kind, monitor);
	if (outputDirectory != null && outputDirectory.exists()) {
		log.debug("refresh output directory: {}", outputDirectory);
		buildContext.refresh(outputDirectory);
	}

	return result;
}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:66,代碼來源:BuildParticipant.java

示例6: build

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的package包/類
@Override
public Set<IProject> build(int kind, final IProgressMonitor monitor) throws Exception {

	final MojoExecution mojoExecution = getMojoExecution();

	if (mojoExecution == null) {
		return null;
	}

	final String phase = mojoExecution.getLifecyclePhase();
	log.debug("phase: {}", phase);

	final String goal = mojoExecution.getGoal();
	log.debug("goal: {}", goal);

	final IMaven maven = MavenPlugin.getMaven();
	final IMavenProjectFacade currentProject = getMavenProjectFacade();
	final BuildContext buildContext = getBuildContext();

	ArtifactKey artifactKey = currentProject.getArtifactKey();
	String shortArtifactKey = artifactKey.getGroupId() 
			+ ":" + artifactKey.getArtifactId() 
			+ ":" + artifactKey.getVersion();
	log.debug("artifact key: {}", shortArtifactKey);

	MavenProject mavenProject = currentProject.getMavenProject();
	File inputPath = maven.getMojoParameterValue(mavenProject, mojoExecution, inputPathParam, File.class, monitor);

	String outputDirectoryPath = mavenProject.getBuild().getDirectory();
	File outputDirectory = new File(outputDirectoryPath);

	if (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind) {
		log.debug("scan resources {}", inputPath);
		Scanner ds = buildContext.newScanner(inputPath);
		ds.scan();
		String[] files = ds.getIncludedFiles();
		if (files == null || files.length <= 0) {
			log.debug("build check: no resource changes");
			log.debug("scan deleted resources {}", inputPath);
			ds = buildContext.newDeleteScanner(inputPath);
			ds.scan();
			files = ds.getIncludedFiles();
			if (files == null || files.length <= 0) {
				return null;
			} else {
				log.debug("build check: resources deleted");
			}
		} else {
			log.debug("build check: resources changed");
		}
	} else {
		log.debug("build check: full build");
	}

	final Set<IProject> result = super.build(kind, monitor);

	IProject project = currentProject.getProject();
	project.refreshLocal(IResource.DEPTH_INFINITE, monitor);

	if (outputDirectory != null && outputDirectory.exists()) {
		log.debug("refresh output directory: {}", outputDirectory);
		buildContext.refresh(outputDirectory);
	}

	return result;
}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:67,代碼來源:GenericBuildParticipant.java

示例7: build

import org.sonatype.plexus.build.incremental.BuildContext; //導入方法依賴的package包/類
@Override
	public Set<IProject> build(int kind, final IProgressMonitor monitor) throws Exception {

		final MojoExecution mojoExecution = getMojoExecution();

		if (mojoExecution == null) {
			return null;
		}

		final String phase = mojoExecution.getLifecyclePhase();
		log.debug("phase: {}", phase);

		final String goal = mojoExecution.getGoal();
		log.debug("goal: {}", goal);

		final IMaven maven = MavenPlugin.getMaven();
		final IMavenProjectFacade currentProject = getMavenProjectFacade();
		final BuildContext buildContext = getBuildContext();
		final IMavenProjectRegistry projectRegistry = MavenPlugin.getMavenProjectRegistry();

		ArtifactKey artifactKey = currentProject.getArtifactKey();
		String shortArtifactKey = artifactKey.getGroupId() + ":" + artifactKey.getArtifactId() + ":" + artifactKey.getVersion();
		log.debug("artifact key: {}", shortArtifactKey);

		MavenProject mavenProject = currentProject.getMavenProject();
		File basedir = mavenProject.getBasedir();
		File resourcesDirectory = new File(basedir, "src");
		String outputDirectoryPath = mavenProject.getBuild().getDirectory();
		File outputDirectory = new File(outputDirectoryPath);

		if (INCREMENTAL_BUILD == kind || AUTO_BUILD == kind) {
			log.debug("scan resources {}", resourcesDirectory);
			Scanner ds = buildContext.newScanner(resourcesDirectory);
			ds.scan();
			String[] files = ds.getIncludedFiles();
			if (files == null || files.length <= 0) {
				log.debug("build check: no resource changes");
				log.debug("scan deleted resources {}", resourcesDirectory);
				ds = buildContext.newDeleteScanner(resourcesDirectory);
				ds.scan();
				files = ds.getIncludedFiles();
				if (files == null || files.length <= 0) {
					return null;
				} else {
					log.debug("build check: resources deleted");
				}
			} else {
				log.debug("build check: resources changed");
			}
		} else {
			log.debug("build check: full build");
		}

		final Set<IProject> result = super.build(kind, monitor);

		IProject project = currentProject.getProject();
		project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
//		IFolder folder = project.getFolder("target");
//		folder.accept(new IResourceVisitor() {
//			@Override
//			public boolean visit(IResource resource) throws CoreException {
//				resource.touch(monitor);
//				return true;
//			}
//		});

		if (outputDirectory != null && outputDirectory.exists()) {
			log.debug("refresh output directory: {}", outputDirectory);
			buildContext.refresh(outputDirectory);
		}

		return result;
	}
 
開發者ID:dashie,項目名稱:m2e-plugins,代碼行數:74,代碼來源:BuildParticipant.java


注:本文中的org.sonatype.plexus.build.incremental.BuildContext.newScanner方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。