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


Java BuildContext類代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:26,代碼來源:RunProtoc.java

示例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;
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:26,代碼來源:PlanContext.java

示例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;
}
 
開發者ID:ArpNetworking,項目名稱:maven-javassist,代碼行數:28,代碼來源:ClassProcessorTask.java

示例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);
}
 
開發者ID:ArpNetworking,項目名稱:maven-javassist,代碼行數:25,代碼來源:ClassProcessorTask.java

示例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;
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:PackageHelper.java

示例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 ());
}
 
開發者ID:phax,項目名稱:ph-schematron,代碼行數:18,代碼來源:Schematron2XSLTMojo.java

示例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);
  }
 
開發者ID:eirslett,項目名稱:frontend-maven-plugin,代碼行數:26,代碼來源:MojoUtils.java

示例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);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:14,代碼來源:YangPluginUtilsTest.java

示例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);
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:12,代碼來源:CssCompilerWrapper.java

示例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);
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:11,代碼來源:CssCompilerWrapper.java

示例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()));
}
 
開發者ID:mikesamuel,項目名稱:closure-maven-plugin,代碼行數:32,代碼來源:GenJavaSymbols.java

示例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);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:31,代碼來源:PackageDataFormatMojo.java

示例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);
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:31,代碼來源:PackageLanguageMojo.java

示例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 );
    }
}
 
開發者ID:mojohaus,項目名稱:templating-maven-plugin,代碼行數:29,代碼來源:AbstractFilterSourcesMojo.java

示例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);
}
 
開發者ID:dobromyslov,項目名稱:gora-maven-plugin,代碼行數:11,代碼來源:AbstractGoraMojo.java


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