本文整理了Java中org.apache.maven.plugin.AbstractMojo
类的一些代码示例,展示了AbstractMojo
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractMojo
类的具体详情如下:
包路径:org.apache.maven.plugin.AbstractMojo
类名称:AbstractMojo
[英]Abstract class to provide most of the infrastructure required to implement a Mojo
except for the execute method.
The implementation should have a Mojo
annotation with the name of the goal:
@Mojo( name = "<goal-name>" )
There are also a number of attributes which can be used to control how and when the Mojo
is executed:
mojo annotation attributesDescriptor ElementAnnotationRequired?Notesgoalname = "<goal-name>"YesThe name for the Mojo that users will reference from the command line to execute the Mojo directly, or inside a POM in order to provide Mojo-specific configuration.implementationnone (detected)YesThe Mojo's fully-qualified class name (or script path in the case of non-Java Mojos).languagenone (detected)No. Default: java
The implementation language for this Mojo (Java, beanshell, etc.).configuratorconfigurator = "<role-hint>"NoThe configurator type to use when injecting parameter values into this Mojo. The value is normally deduced from the Mojo's implementation language, but can be specified to allow a custom ComponentConfigurator implementation to be used.
NOTE: This will only be used in very special cases, using a highly controlled vocabulary of possible values. (Elements like this are why it's a good idea to use the descriptor tools.)phasedefaultPhase = LifecyclePhase.<phase>NoBinds this Mojo to a particular phase of the standard build lifecycle, if specified.
NOTE: This is only required if this Mojo is to participate in the standard build process.execute@Execute ( phase=LifecyclePhase.<phase>, goal= "<goal-name>", lifecycle="<lifecycle-id>" )NoWhen this goal is invoked, it will first invoke a parallel lifecycle, ending at the given phase. If a goal is provided instead of a phase, that goal will be executed in isolation. The execution of either will not affect the current project, but instead make available the ${executedProject}
expression if required. An alternate lifecycle can also be provided: for more information see the documentation on the build lifecycle. requiresDependencyResolutionrequiresDependencyResolution = ResolutionScope.<scope>NoFlags this Mojo as requiring the dependencies in the specified scope (or an implied scope) to be resolved before it can execute.
NOTE: Currently supports compile, runtime, and test scopes.descriptionnone (detected)NoThe description of this Mojo's functionality. Using the toolset, this will be the class-level Javadoc description provided.
NOTE: While this is not a required part of the Mojo specification, it SHOULD be provided to enable future tool support for browsing, etc. and for clarity.parametersN/ANoSpecifications for the parameters which this Mojo uses will be provided in parameter sub-elements in this section.
NOTE: Parameters are discussed in more detail below.
This is only a small set of all the options. A complete list can be found at Maven Plugin Tool for Annotations.
[中]抽象类提供实现Mojo
所需的大部分基础结构,execute方法除外。
实现应该有一个带有目标名称的Mojo
注释:
@Mojo( name = "<goal-name>" )
还有许多属性可用于控制Mojo
的执行方式和时间:
mojo注释属性描述符元素AnnotationRequired?Notesgoalname=“<goal name>”是用户将从命令行直接引用以执行Mojo的Mojo的名称,或在POM内引用以提供特定于Mojo的配置。implementationnone(detected)是Mojo的完全限定类名(或非Java Mojo的脚本路径)。languagenone(检测到)否。默认值:java
此Mojo(Java、beanshell等)的实现语言。configuratorconfigurator=“<role hint>”将参数值注入此Mojo时要使用的配置器类型。该值通常由Mojo的实现语言推导而来,但可以指定为允许使用自定义ComponentConfigurator实现。
注意:这将仅在非常特殊的情况下使用,使用高度控制的可能值词汇表。(这就是为什么使用描述符工具是个好主意。)phasedefaultPhase=生命周期数据库<阶段>如果指定,则不将此Mojo绑定到标准构建生命周期的特定阶段。
注意:只有当这个Mojo要参与标准的构建过程时,这才是必需的。execute@Execute(phase=LifecycleBase.<phase>,goal=“<goal name>”,lifecycle=“<lifecycle id>”)现在调用此目标时,它将首先调用并行生命周期,并在给定阶段结束。如果提供了一个目标而不是一个阶段,那么该目标将单独执行。任何一个表达式的执行都不会影响当前项目,而是在需要时提供${executedProject}
表达式。还可以提供另一个生命周期:有关更多信息,请参阅build lifecycle上的文档。requiresDependencyResolutionrequiresDependencyResolution=分辨率范围<scope>no将此Mojo标记为需要解析指定范围(或隐含范围)中的依赖项才能执行。
注意:当前支持编译、运行时和测试范围。description无(检测到)无此Mojo功能的描述。使用该工具集,这将是提供的类级Javadoc描述。
注意:虽然这不是Mojo规范的必需部分,但为了使将来能够支持浏览等工具,以及为了清晰起见,应该提供它。参数本节中的参数子元素将提供此Mojo使用的参数的规范。
注:下面将更详细地讨论参数。
这只是所有选项的一小部分。完整的列表可以在Maven Plugin Tool for Annotations找到。
代码示例来源:origin: simpligility/android-maven-plugin
protected Jack getJack()
{
if ( jack == null )
{
return new Jack( super.getPluginContext() );
}
else
{
return jack;
}
}
代码示例来源:origin: org.apache.maven.plugins/maven-idea-plugin
public Log getLog()
{
if ( log == null )
{
log = super.getLog();
}
return log;
}
}
代码示例来源:origin: net.java.truelicense/truelicense-maven-plugin
@Override
public void setLog(final Log log) {
super.setLog(log);
this.checkedLog = null;
}
代码示例来源:origin: com.pyx4j/maven-plugin-log4j
public static void startPluginLog(AbstractMojo mojo) {
mavenLog = mojo.getLog();
}
代码示例来源:origin: christian-schlichtherle/truelicense
@Override
public void setLog(final Log log) {
super.setLog(log);
checkedLog = null;
}
代码示例来源:origin: org.apache.cayenne.plugins/cayenne-maven-plugin
public MavenLogger(AbstractMojo parent) {
this.logger = parent.getLog();
}
代码示例来源:origin: com.github.marcosemiao.maven.plugin.logger/maven-plugin-logger
@Override
public void setLog(final Log log) {
super.setLog(log);
MojoLoggerHolder.mojoLogger.setMavenLogger(log);
}
代码示例来源:origin: org.apache.npanday.plugins/maven-compile-plugin
outputDirectory + ", File Count = " + files.length );
super.getPluginContext().put( "SOURCE_FILES_UP_TO_DATE", Boolean.TRUE );
for ( String file : files )
if ( sourceFile.lastModified() > targetFile.lastModified() )
super.getPluginContext().put( "SOURCE_FILES_UP_TO_DATE", Boolean.FALSE );
FileUtils.copyFile( sourceFile, targetFile );
targetFile.setLastModified( System.currentTimeMillis() );
代码示例来源:origin: org.scala-tools/maven-scala-plugin
@Override
public void addJvmArgs(String... args) {
//TODO - Ignore classpath
if (args != null) {
for (String arg : args) {
requester.getLog().warn("jvmArgs are ignored when run in process :" + arg);
}
}
}
代码示例来源:origin: org.sonatype.plugins/nexus-staging-maven-plugin
public void setLog(Log log) {
super.setLog(log);
LogbackUtils.syncLogLevelWithMaven(log);
}
代码示例来源:origin: org.apache.npanday.plugins/maven-compile-plugin
Boolean sourceFilesUpToDate = (Boolean) super.getPluginContext().get("SOURCE_FILES_UP_TO_DATE");
if (((sourceFilesUpToDate == null) || sourceFilesUpToDate) &&
System.getProperty("forceCompile") == null && compilerExecutable.getCompiledArtifact() != null &&
代码示例来源:origin: org.scala-tools/maven-scala-plugin
public void redirectToLog() {
requester.getLog().warn("redirection to log is not supported for 'inProcess' mode");
}
代码示例来源:origin: org.echocat.jomon.maven.plugins/common
@Override
public void setLog(Log log) {
super.setLog(log);
StaticLoggerBinder.getSingleton().setLog(log);
}
代码示例来源:origin: org.scala-tools/maven-scala-plugin
@Override
protected void processLine(String line, @SuppressWarnings("unused") int level) {
if (line.toLowerCase().indexOf("error") > -1) {
requester.getLog().error(line);
} else if (line.toLowerCase().indexOf("warn") > -1) {
requester.getLog().warn(line);
} else {
requester.getLog().info(line);
}
}
}));
代码示例来源:origin: io.teecube.t3/t3-common
@Override
@SuppressWarnings("unchecked")
public <T> T getConfiguredMojo(Class<T> mojoInterface, final MavenSession session, MojoExecution mojoExecution) throws PluginConfigurationException, PluginContainerException {
final T configuredMojo = super.getConfiguredMojo(mojoInterface, session, mojoExecution); // retrieve configuredMojo to know the actual type of the Mojo to configure
if (this.silentMojo) {
((AbstractMojo) configuredMojo).setLog(new NoOpLogger());
}
Class<? extends CommonMojo> type;
try {
type = (Class<? extends CommonMojo>) configuredMojo.getClass();
if (!(configuredMojo instanceof CommonMojo)) {
return configuredMojo;
}
} catch (ClassCastException e) {
return configuredMojo;
}
T rawMojo = (T) mojosFactory.getMojo(type); // retrieve a brand new and unconfigured Mojo of the actual type (with annotations)
if (rawMojo != null) { // inject @MojoParameter and @GlobalParameter annotations
Injector i = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bindListener(Matchers.any(), getListener(configuredMojo, session.getCurrentProject(), session)); // WARN: using getCurrentProject() ?
}
});
i.injectMembers(rawMojo); // will also inject in configuredMojo
}
return configuredMojo;
}
代码示例来源:origin: org.scala-tools/maven-scala-plugin
private void displayCmd(boolean displayCmd, List<String> cmd) {
if (displayCmd) {
requester.getLog().info("cmd: " + " " + StringUtils.join(cmd.iterator(), " "));
} else if (requester.getLog().isDebugEnabled()) {
requester.getLog().debug("cmd: " + " " + StringUtils.join(cmd.iterator(), " "));
}
}
代码示例来源:origin: org.kuali.maven.common/maven-kuali-common
public void handleMajorVersion(AbstractMojo mojo, MavenProject project, String property) {
String majorVersion = getMajorVersion(project.getVersion());
if (!StringUtils.isEmpty(majorVersion)) {
project.getProperties().setProperty(property, majorVersion);
mojo.getLog().info(property + "=" + majorVersion);
} else {
mojo.getLog().info("Major version could not be determined");
}
}
代码示例来源:origin: org.scala-tools/maven-scala-plugin
public JavaMainCallerInProcess(AbstractMojo requester, String mainClassName, String classpath, String[] jvmArgs, String[] args) throws Exception {
super(requester, mainClassName, "", jvmArgs, args);
//Pull out classpath and create class loader
ArrayList<URL> urls = new ArrayList<URL>();
for(String path : classpath.split(File.pathSeparator)) {
try {
urls.add(new File(path).toURI().toURL());
} catch (MalformedURLException e) {
//TODO - Do something usefull here...
requester.getLog().error(e);
}
}
_cl = new URLClassLoader(urls.toArray(new URL[urls.size()]), (ClassLoader)null);
}
代码示例来源:origin: paypal/SeLion
@Override
public CodeGeneratorMojoLogger getLog() {
final CodeGeneratorMojoLogger log = new CodeGeneratorMojoLogger(super.getLog());
return log;
}
代码示例来源:origin: net.java.truelicense/truelicense-maven-plugin
@Override
public Log getLog() {
final CheckedLog cl = checkedLog;
return null != cl ? cl : (checkedLog = new CheckedLog(super.getLog()));
}
}
内容来源于网络,如有侵权,请联系作者删除!