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


Java BuildContext.refresh方法代码示例

本文整理汇总了Java中org.sonatype.plexus.build.incremental.BuildContext.refresh方法的典型用法代码示例。如果您正苦于以下问题:Java BuildContext.refresh方法的具体用法?Java BuildContext.refresh怎么用?Java BuildContext.refresh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sonatype.plexus.build.incremental.BuildContext的用法示例。


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

示例1: try

import org.sonatype.plexus.build.incremental.BuildContext; //导入方法依赖的package包/类
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
/* package private */ void writeClass(
        final CtClass ctClass,
        final Path outputDirectory,
        final BuildContext context) {
    // Translate the class name to a file path
    final File classFile = outputDirectory.resolve(
            Paths.get(ctClass.getName().replace('.', '/') + ".class")).toFile();

    // Ensure the containing directory structure exsits
    final File classDirectory = classFile.getParentFile();
    classDirectory.mkdirs();

    // Write the class to the file
    try (DataOutputStream outputStream = new DataOutputStream(
            new BufferedOutputStream(context.newFileOutputStream(classFile)))) {
        _ctClass.toBytecode(outputStream);
    } catch (final IOException | CannotCompileException e) {
        throw new RuntimeException(e);
    }

    // Update the build context
    context.refresh(classDirectory);
}
 
开发者ID:ArpNetworking,项目名称:maven-javassist,代码行数:25,代码来源:ClassProcessorTask.java

示例2: 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

示例3: dirRemove

import org.sonatype.plexus.build.incremental.BuildContext; //导入方法依赖的package包/类
/**
 * Delete a directory and its content.
 *
 * @param dir the directory to remove.
 * @throws IOException on error.
 * @since 3.3
 */
public final void dirRemove(File dir) throws IOException {
	if (dir != null) {
		getLog().debug("Deleting tree: " + dir.toString()); //$NON-NLS-1$
		final LinkedList<File> candidates = new LinkedList<>();
		candidates.add(dir);
		File[] children;
		final BuildContext buildContext = getBuildContext();
		while (!candidates.isEmpty()) {
			final File f = candidates.getFirst();
			getLog().debug("Scanning: " + f); //$NON-NLS-1$
			if (f.isDirectory()) {
				children = f.listFiles();
				if (children != null && children.length > 0) {
					// Non empty directory
					for (final File c : children) {
						getLog().debug("Discovering: " + c); //$NON-NLS-1$
						candidates.push(c);
					}
				} else {
					// empty directory
					getLog().debug("Deleting: " + f); //$NON-NLS-1$
					candidates.removeFirst();
					f.delete();
					buildContext.refresh(f.getParentFile());
				}
			} else {
				// not a directory
				candidates.removeFirst();
				if (f.exists()) {
					getLog().debug("Deleting: " + f); //$NON-NLS-1$
					f.delete();
					buildContext.refresh(f.getParentFile());
				}
			}
		}
		getLog().debug("Deletion done"); //$NON-NLS-1$
	}
}
 
开发者ID:gallandarakhneorg,项目名称:afc,代码行数:46,代码来源:AbstractArakhneMojo.java

示例4: doExecute

import org.sonatype.plexus.build.incremental.BuildContext; //导入方法依赖的package包/类
protected void doExecute() throws MojoExecutionException {
	setupLogging();
	if (getVerbose())
		getLog().info("Started execution.");
	setupMavenPaths();
	setupCatalogResolver();
	setupEntityResolver();
	setupSchemaFiles();
	setupBindingFiles();
	setupSchemas();
	setupBindings();
	setupDependsURIs();
	setupProducesURIs();
	setupURILastModifiedResolver();
	if (getVerbose()) {
		logConfiguration();
	}

	final OptionsConfiguration optionsConfiguration = createOptionsConfiguration();

	if (getVerbose()) {
		getLog().info("optionsConfiguration:" + optionsConfiguration);
	}

	checkCatalogsInStrictMode();

	if (getGrammars().isEmpty()) {
		getLog().warn("No schemas to compile. Skipping XJC execution. ");
	} else {

		final O options = getOptionsFactory().createOptions(optionsConfiguration);

		if (getForceRegenerate()) {
			getLog().warn("You are using forceRegenerate=true in your configuration.\n"
					+ "This configuration setting is deprecated and not recommended "
					+ "as it causes problems with incremental builds in IDEs.\n"
					+ "Please refer to the following link for more information:\n"
					+ "https://github.com/highsource/maven-jaxb2-plugin/wiki/Do-Not-Use-forceRegenerate\n"
					+ "Consider removing this setting from your plugin configuration.\n");
			getLog().info("The [forceRegenerate] switch is turned on, XJC will be executed.");
		} else {
			final boolean isUpToDate = isUpToDate();
			if (!isUpToDate) {
				getLog().info("Sources are not up-to-date, XJC will be executed.");
			} else {
				getLog().info("Sources are up-to-date, XJC will be skipped.");
				return;
			}
		}

		setupDirectories();
		doExecute(options);
		addIfExistsToEpisodeSchemaBindings();
		final BuildContext buildContext = getBuildContext();
		getLog().debug(MessageFormat.format("Refreshing the generated directory [{0}].",
				getGenerateDirectory().getAbsolutePath()));
		buildContext.refresh(getGenerateDirectory());
	}

	if (getVerbose()) {
		getLog().info("Finished execution.");
	}
}
 
开发者ID:highsource,项目名称:maven-jaxb2-plugin,代码行数:64,代码来源:RawXJC2Mojo.java

示例5: 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

示例6: 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

示例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();

	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

示例8: 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

示例9: addToCompilationRoot

import org.sonatype.plexus.build.incremental.BuildContext; //导入方法依赖的package包/类
/**
 * Adds generated source directory to the compilation root.
 *
 * @param source  directory
 * @param project current maven project
 * @param context current build context
 */
public static void addToCompilationRoot(String source, MavenProject project, BuildContext context) {
    project.addCompileSourceRoot(source);
    context.refresh(project.getBasedir());
    log.info("Source directory added to compilation root: " + source);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:13,代码来源:YangPluginUtils.java


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