我有一个插件(antrun),其执行配置具有id并且不绑定到任何阶段.我可以直接从命令行执行此执行吗?
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>my-execution</id>
...
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
用它来运行它:
mvn my-execution
Run Code Online (Sandbox Code Playgroud)
或至少
mvn magicplugin:execute -DexecutionId=my-execution
Run Code Online (Sandbox Code Playgroud) TL; DR版本:我希望能够使用Maven Mojo SQL插件通过mvn命令行随意创建/删除我的数据库模式中的任何给定表(或者为这些表加载数据).怎么样?
我是一名长期的Java开发人员,但在大多数情况下,我一直生活在一个ant基于世界的领域.我喜欢它的力量和显而易见性ant,以及它给我带来的控制力.然而,在我的新工作中,有一种推动使用maven.所以我决定使用我在家工作的项目来学习它.
我在不同的个人项目上设置的一件事是能够ant从命令行完全设置和拆除我的Postgres数据库.我可以单独或一致地对任何表格,序列和集成测试数据进行切片和切块.当然,这意味着我有大约一个ant目标,但它的效果非常好.我喜欢这个; 多年来它一直很好用.
在研究如何在周末在Maven中完成此任务时,我找到了Mojo SQL Maven插件.在查看使用情况页面(我使用该术语时,因为它实际上只是一个没有解释的半示例)和示例页面后,我能够对我的pom.xml文件进行一些更改.我在示例(postgressql)中修复了一些明显的拼写错误,并引用了PostgreSQL JDBC页面以确保我的JDBC连接字符串正确.我将粘贴所有pom.xml(修改为保护有罪)下面:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.myapp</groupId>
<artifactId>myapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>JBoss</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.0.0.CR7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.5</version>
<dependencies>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-606.jdbc4</version>
</dependency>
</dependencies>
<configuration> …Run Code Online (Sandbox Code Playgroud) 我想mvn dependency:analyze从命令行使用来手动检查依赖关系问题。问题是我找不到在pom.xml. 必须在命令行中提供所有参数。
所以我必须总是使用
mvn dependency:analyze -DignoreNonCompile
Run Code Online (Sandbox Code Playgroud)
什么,我缺少的是设定的方式ignoreNonCompile在pom.xml在插件配置。
像这样的东西:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>analyze</id>
<goals>
<goal>analyze</goal>
</goals>
<configuration>
<ignoreNonCompile>true</ignoreNonCompile>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
但这不起作用。
如果我使用
<goal>analyze-only</goal>
Run Code Online (Sandbox Code Playgroud)
然后在构建期间运行插件,并使用配置。但我不想让它在构建中运行,只能手动请求。并且手动运行不会遵守该参数。
我可以在pom.xmlnamed 中设置一个属性ignoreNonCompile,但这将在构建中设置此参数并手动运行。
有没有办法只配置 的行为mvn dependency:analyze?