本文整理匯總了Java中org.sonatype.plexus.build.incremental.BuildContext類的典型用法代碼示例。如果您正苦於以下問題:Java BuildContext類的具體用法?Java BuildContext怎麽用?Java BuildContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BuildContext類屬於org.sonatype.plexus.build.incremental包,在下文中一共展示了BuildContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processLine
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
@Override
public void processLine(String line) {
Matcher m = MESSAGE.matcher(line);
if (m.find()) {
String file = m.group(1);
int lineno, column;
String message;
if (file != null) {
lineno = Integer.parseInt(m.group(2));
column = Integer.parseInt(m.group(3));
message = line.substring(m.end());
} else {
file = m.group(4);
lineno = column = 1;
message = line;
}
// Assumes buildContext is internally synchronized.
buildContext.addMessage(
new File(file), lineno, column, message,
BuildContext.SEVERITY_ERROR,
null);
} else {
log.info("protoc: " + line);
}
}
示例2: PlanContext
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
/** */
public PlanContext(
ProcessRunner processRunner,
PluginDescriptor pluginDescriptor,
BuildContext buildContext,
Log log,
SrcfilesDirs srcfilesDirs,
GenfilesDirs genfilesDirs,
ImmutableList<Artifact> artifacts,
File outputDir,
File projectBuildOutputDirectory,
File closureOutputDirectory,
StableCssSubstitutionMapProvider substitutionMapProvider) {
this.processRunner = processRunner;
this.pluginDescriptor = pluginDescriptor;
this.buildContext = buildContext;
this.log = log;
this.srcfilesDirs = srcfilesDirs;
this.genfilesDirs = genfilesDirs;
this.artifacts = artifacts;
this.outputDir = outputDir;
this.projectBuildOutputDirectory = projectBuildOutputDirectory;
this.closureOutputDirectory = closureOutputDirectory;
this.substitutionMapProvider = substitutionMapProvider;
}
示例3: ClassProcessorTask
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
/**
* Constructor.
*
* @param context The {@code BuildContext} instance.
* @param ctClass The {@code CtClass} instance to conditionally process.
* @param processor The {@code ClassProcessor} instance to apply if included.
* @param includePredicate The {@code Predicate} to include an element in processing.
* @param excludePredicate The {@code Predicate} to exclude an element from processing.
* @param outputDirectory The output directory to write the transformed class to.
* @param log The {@code Log} instance to record processing to.
*/
ClassProcessorTask(
final BuildContext context,
final CtClass ctClass,
final ClassProcessor processor,
final Predicate<CtClass> includePredicate,
final Predicate<CtClass> excludePredicate,
final Path outputDirectory,
final Log log) {
_context = context;
_ctClass = ctClass;
_processor = processor;
_includePredicate = includePredicate;
_excludePredicate = excludePredicate;
_outputDirectory = outputDirectory;
_log = log;
}
示例4: 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);
}
示例5: haveResourcesChanged
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
public static boolean haveResourcesChanged(Log log, MavenProject project, BuildContext buildContext, String suffix) {
String baseDir = project.getBasedir().getAbsolutePath();
for (Resource r : project.getBuild().getResources()) {
File file = new File(r.getDirectory());
if (file.isAbsolute()) {
file = new File(r.getDirectory().substring(baseDir.length() + 1));
}
String path = file.getPath() + "/" + suffix;
log.debug("checking if " + path + " (" + r.getDirectory() + "/" + suffix + ") has changed.");
if (buildContext.hasDelta(path)) {
log.debug("Indeed " + suffix + " has changed.");
return true;
}
}
return false;
}
示例6: internalLog
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
@Override
protected void internalLog (@Nonnull final IError aResError)
{
final int nLine = aResError.getErrorLocation ().getLineNumber ();
final int nColumn = aResError.getErrorLocation ().getColumnNumber ();
final String sMessage = StringHelper.getImplodedNonEmpty (" - ",
aResError.getErrorText (Locale.US),
aResError.getLinkedExceptionMessage ());
// 0 means undefined line/column
buildContext.addMessage (m_aSourceFile,
nLine <= 0 ? 0 : nLine,
nColumn <= 0 ? 0 : nColumn,
sMessage,
aResError.isError () ? BuildContext.SEVERITY_ERROR : BuildContext.SEVERITY_WARNING,
aResError.getLinkedExceptionCause ());
}
示例7: 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);
}
示例8: testForAddSource
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
/**
* This test case checks whether the source is getting added.
*/
@Test
public void testForAddSource() throws IOException {
MavenProject project = new MavenProject();
BuildContext context = new DefaultBuildContext();
File sourceDir = new File(BASE_DIR + File.separator + "yang");
sourceDir.mkdirs();
addToCompilationRoot(sourceDir.toString(), project, context);
FileUtils.deleteDirectory(sourceDir);
}
示例9: report
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
@Override
public void report(GssError error) {
hasErrors = true;
buildContext.addMessage(
new File(error.getLocation().getSourceCode().getFileName()),
error.getLocation().getBeginLineNumber(),
error.getLocation().getBeginIndexInLine(),
error.getMessage(),
BuildContext.SEVERITY_ERROR,
null);
}
示例10: reportWarning
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
@Override
public void reportWarning(GssError warning) {
buildContext.addMessage(
new File(warning.getLocation().getSourceCode().getFileName()),
warning.getLocation().getBeginLineNumber(),
warning.getLocation().getBeginIndexInLine(),
warning.getMessage(),
BuildContext.SEVERITY_WARNING,
null);
}
示例11: filterUpdates
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
@Override
protected void filterUpdates() throws IOException, MojoExecutionException {
BuildContext bc = context.buildContext;
ImmutableSet.Builder<Source> unchanged = ImmutableSet.builder();
ImmutableSet.Builder<Source> changed = ImmutableSet.builder();
ImmutableSet.Builder<Source> defunct = ImmutableSet.builder();
if (sourceUpdate.isPresent() && bc.isIncremental()) {
Set<Source> unchangedSet = Sets.newLinkedHashSet();
unchangedSet.addAll(sourceUpdate.get().allExtant());
for (TypedFile root : outputFileSpec.roots) {
ImmutableList<Source> deltaPaths = outputFileSpec.scan(
bc.newScanner(root.f, false), root.ps);
ImmutableList<Source> deletedPaths = outputFileSpec.scan(
bc.newDeleteScanner(root.f), root.ps);
changed.addAll(deltaPaths);
defunct.addAll(deletedPaths);
unchangedSet.removeAll(deltaPaths);
unchangedSet.removeAll(deletedPaths);
}
unchanged.addAll(unchangedSet);
} else {
changed.addAll(Sources.scan(context.log, outputFileSpec).sources);
}
this.sourceUpdate = Optional.of(new Update<>(
unchanged.build(),
changed.build(),
defunct.build()));
}
示例12: readClassFromCamelResource
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
// skip directories as there may be a sub .resolver directory
if (file.isDirectory()) {
return null;
}
String name = file.getName();
if (name.charAt(0) != '.') {
if (buffer.length() > 0) {
buffer.append(" ");
}
buffer.append(name);
}
if (!buildContext.hasDelta(file)) {
// if this file has not changed,
// then no need to store the javatype
// for the json file to be generated again
// (but we do need the name above!)
return null;
}
// find out the javaType for each data format
try {
String text = loadText(new FileInputStream(file));
Map<String, String> map = parseAsMap(text);
return map.get("class");
} catch (IOException e) {
throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
}
}
示例13: readClassFromCamelResource
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
private static String readClassFromCamelResource(File file, StringBuilder buffer, BuildContext buildContext) throws MojoExecutionException {
// skip directories as there may be a sub .resolver directory such as in camel-script
if (file.isDirectory()) {
return null;
}
String name = file.getName();
if (name.charAt(0) != '.') {
if (buffer.length() > 0) {
buffer.append(" ");
}
buffer.append(name);
}
if (!buildContext.hasDelta(file)) {
// if this file has not changed,
// then no need to store the javatype
// for the json file to be generated again
// (but we do need the name above!)
return null;
}
// find out the javaType for each data format
try {
String text = loadText(new FileInputStream(file));
Map<String, String> map = parseAsMap(text);
return map.get("class");
} catch (IOException e) {
throw new MojoExecutionException("Failed to read file " + file + ". Reason: " + e, e);
}
}
示例14: filterSourceToTemporaryDir
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
private void filterSourceToTemporaryDir( final File sourceDirectory, final File temporaryDirectory )
throws MojoExecutionException
{
List<Resource> resources = new ArrayList<Resource>();
Resource resource = new Resource();
resource.setFiltering( true );
logDebug( "Source absolute path: %s", sourceDirectory.getAbsolutePath() );
resource.setDirectory( sourceDirectory.getAbsolutePath() );
resources.add( resource );
MavenResourcesExecution mavenResourcesExecution =
new MavenResourcesExecution( resources, temporaryDirectory, project, encoding,
Collections.<String>emptyList(), Collections.<String>emptyList(), session );
mavenResourcesExecution.setInjectProjectBuildFilters( true );
mavenResourcesExecution.setEscapeString( escapeString );
mavenResourcesExecution.setOverwrite( overwrite );
setDelimitersForExecution( mavenResourcesExecution );
try
{
mavenResourcesFiltering.filterResources( mavenResourcesExecution );
}
catch ( MavenFilteringException e )
{
buildContext.addMessage( getSourceDirectory(), 1, 1, "Filtering Exception", BuildContext.SEVERITY_ERROR,
e );
throw new MojoExecutionException( e.getMessage(), e );
}
}
示例15: attachErrorMessage
import org.sonatype.plexus.build.incremental.BuildContext; //導入依賴的package包/類
private void attachErrorMessage(JsonParseException e) {
JsonLocation location = e.getLocation();
File file;
if (location.getSourceRef() instanceof File) {
file = (File) location.getSourceRef();
} else {
file = null;
}
context.addMessage(file, location.getLineNr(), location.getColumnNr(), e.getLocalizedMessage(), BuildContext.SEVERITY_ERROR, e);
}