java mojo是什么_在maven插件中获取mojo参数

好吧,经过多次调试,我能够根据AbstractConfigurationConverter的工作原理,特别是fromExpression方法来计算它。

要获得属性,您需要将以下内容添加到您的mojo中:

@Parameter(defaultValue = "${session}")

protected MavenSession session;

@Parameter(defaultValue = "${mojoExecution}")

protected MojoExecution mojoExecution;

从那里,您现在可以创建一个求值器和配置(也许您可以直接将它们注入,我不确定),然后您可以这样做:

PluginParameterExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator(session, mojoExecution);

PlexusConfiguration pomConfiguration = new XmlPlexusConfiguration(mojoExecution.getConfiguration());

for (PlexusConfiguration plexusConfiguration : pomConfiguration.getChildren()) {

String value = plexusConfiguration.getValue();

String defaultValue = plexusConfiguration.getAttribute("default-value");

try {

String evaluated = defaultIfNull(expressionEvaluator.evaluate(defaultIfBlank(value, defaultValue)), "").toString();

System.out.println(plexusConfiguration.getName() + " -> " + defaultIfBlank(evaluated, defaultValue));

} catch (ExpressionEvaluationException e) {

e.printStackTrace();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以通过maven件 `exec-maven-plugin` 来启动flume的agent。具体步骤如下: 1. 在 `pom.xml` 文件添加 `exec-maven-plugin` 件的依赖: ```xml <dependencies> <dependency> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> </dependency> </dependencies> ``` 2. 在 `pom.xml` 文件添加 `exec-maven-plugin` 件的配置: ```xml <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <id>start-flume-agent</id> <phase>pre-integration-test</phase> <goals> <goal>exec</goal> </goals> <configuration> <executable>flume-ng</executable> <arguments> <argument>agent</argument> <argument>-n</argument> <argument>agent1</argument> <argument>-c</argument> <argument>conf</argument> <argument>-f</argument> <argument>flume-conf.properties</argument> </arguments> </configuration> </execution> </executions> </plugin> </plugins> </build> ``` 3. 在 `conf` 目录下创建 `flume-conf.properties` 文件,并添加 flume agent 的配置信息。 4. 在 `src/test/java` 目录下创建一个测试类,编写测试代码来发送数据给 flume 的 agent。 5. 在 idea 执行 `mvn test` 命令,会自动启动 flume 的 agent,并执行测试代码发送数据。 以上配置,`-n` 参数指定了 flume agent 的名称,`-c` 参数指定了 flume 配置文件所在的目录,`-f` 参数指定了 flume 配置文件的文件名。在实际操作,需要根据具体的情况进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值