org.apache.maven.plugin.Mojo类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(383)

本文整理了Java中org.apache.maven.plugin.Mojo类的一些代码示例,展示了Mojo类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mojo类的具体详情如下:
包路径:org.apache.maven.plugin.Mojo
类名称:Mojo

Mojo介绍

[英]This interface forms the contract required for Mojos to interact with the Maven infrastructure.
It features an execute() method, which triggers the Mojo's build-process behavior, and can throw a MojoExecutionException or MojoFailureException if error conditions occur.
Also included is the setLog(...) method, which simply allows Maven to inject a logging mechanism which will allow the Mojo to communicate to the outside world through standard Maven channels.
[中]此接口构成MojosMaven基础设施交互所需的合同。
它具有一个execute()方法,该方法触发Mojo的构建过程行为,如果出现错误情况,可以抛出MojoExecutionException或MojoFailureException。
还包括setLog(...)方法,它只允许Maven注入一个日志机制,允许Mojo通过标准Maven通道与外部世界通信。

代码示例

代码示例来源:origin: apache/storm

public int run(List<String> command, List<String> output) {
  int retCode = 1;
  ProcessBuilder pb = new ProcessBuilder(command);
  try {
    Process p = pb.start();
    OutputBufferThread stdOut = new OutputBufferThread(p.getInputStream());
    OutputBufferThread stdErr = new OutputBufferThread(p.getErrorStream());
    stdOut.start();
    stdErr.start();
    retCode = p.waitFor();
    if (retCode != 0) {
      mojo.getLog().warn(command + " failed with error code " + retCode);
      for (String s : stdErr.getOutput()) {
        mojo.getLog().debug(s);
      }
    }
    stdOut.join();
    stdErr.join();
    output.addAll(stdOut.getOutput());
  } catch (Exception ex) {
    mojo.getLog().warn(command + " failed: " + ex.toString());
  }
  return retCode;
}

代码示例来源:origin: apache/maven

mojo.execute();

代码示例来源:origin: apache/maven

( (Mojo) mojo ).setLog( new DefaultLog( mojoLogger ) );

代码示例来源:origin: net.sf.staccatocommons/staccatissimo-instrument

/**
 * Executes the mojo
 * 
 * @throws MojoExecutionException
 * @throws MojoFailureException
 */
public void execute() throws MojoExecutionException, MojoFailureException {
 mojo.getLog().info("Instrumenting classes located in " + location);
 String extraClasspath = createClassPathString();
 mojo.getLog().debug("Using classpath " + extraClasspath);
 try {
  InstrumentationRunner.runInstrumentation(//
   createConfigurer(),
   new Directory(location),
   extraClasspath);
 } catch (Exception e) {
  mojo.getLog().error(e.getMessage());
  throw new MojoExecutionException("Unexpected error", e);
 }
 mojo.getLog().info("Classes instrumented sucessfully");
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void info(String msg) {
 if (verbose) {
  mojo.getLog().info(msg);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void debug(String msg) {
 if (verbose) {
  mojo.getLog().debug(msg);
 }
}

代码示例来源:origin: org.wisdom-framework/wisdom-maven-plugin

mojo.getLog().debug("Creating error file for '" + e.getMessage() + "' happening at " + e.getLine() + ":" + e
    .getCharacter() + " of " + e.getFile() + ", created by watcher : " + watcher);
JSONObject obj = new JSONObject();
  FileUtils.writeStringToFile(getErrorFileForWatcher(watcher), obj.toJSONString(), false);
} catch (IOException e1) {
  mojo.getLog().error("Cannot write the error file", e1);

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void warn(String msg, Throwable t) {
 if (verbose) {
  mojo.getLog().warn(msg, t);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void error(String msg) {
 if (verbose) {
  mojo.getLog().error(msg);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public boolean isInfoEnabled() {
 return mojo.getLog().isInfoEnabled();
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public boolean isDebugEnabled() {
 return mojo.getLog().isDebugEnabled();
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public boolean isWarnEnabled() {
 return mojo.getLog().isWarnEnabled();
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public boolean isErrorEnabled() {
 return mojo.getLog().isErrorEnabled();
}

代码示例来源:origin: org.apache.geronimo.genesis.plugins/plugin-support

private org.apache.maven.plugin.logging.Log getLog() {
  if (mojo == null) {
    throw new RuntimeException("Mojo not set; can not delegate logging");
  }
  return mojo.getLog();
}

代码示例来源:origin: org.wisdom-framework/wisdom-maven-plugin

mojo.getLog().info(EMPTY_STRING);
mojo.getLog().info("The watcher has detected a change in " + file.getAbsolutePath());
mojo.getLog().info(EMPTY_STRING);
for (Watcher watcher : watchers) {
  if (watcher.accept(file)) {
      continueProcessing = watcher.fileUpdated(file);
    } catch (WatchingException e) { //NOSONAR
      mojo.getLog().debug(watcher + " has thrown an exception while handling the " + file.getName() + EMPTY_STRING +
          " update", e);
      mojo.getLog().error(String.format(WATCHING_EXCEPTION_MESSAGE, e.getMessage()));
      createErrorFile(watcher, e);
      continueProcessing = false;
mojo.getLog().info(EMPTY_STRING);
mojo.getLog().info(EMPTY_STRING);

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void info(String msg, Throwable t) {
 if (verbose) {
  mojo.getLog().info(msg, t);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void debug(String msg, Throwable t) {
 if (verbose) {
  mojo.getLog().debug(msg, t);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void warn(String msg) {
 if (verbose) {
  mojo.getLog().warn(msg);
 }
}

代码示例来源:origin: git-commit-id/maven-git-commit-id-plugin

@Override
public void error(String msg, Throwable t) {
 if (verbose) {
  mojo.getLog().error(msg, t);
 }
}

代码示例来源:origin: pl.project13.maven/git-commit-id-plugin

@Override
public boolean isInfoEnabled() {
 return mojo.getLog().isInfoEnabled();
}

相关文章