powershell 中运行 -Dmaven.test.skip : Unknown lifecycle phase “.test.skip=true”
参考:cannot-run-maven-using-mvn-d-argument-within-microsoft-powershell-but-works
When you run into problems with PowerShell's interpretation of arguments to be passed to a console EXE, try using the echoargs.exe utility that comes with the PowerShell Community Extensions. With this tool you can see how PowerShell supplies the arguments to the EXE e.g.:
PS> echoargs mvn clean install -Dmaven.test.skip=true
Arg 0 is <mvn>
Arg 1 is <clean>
Arg 2 is <install>
Arg 3 is <-Dmaven>
Arg 4 is <.test.skip=true>
PS> echoargs mvn clean install '-Dmaven.test.skip=true'
Arg 0 is <mvn>
Arg 1 is <clean>
Arg 2 is <install>
Arg 3 is <-Dmaven.test.skip=true>
Short answer - use quoting '-Dmaven.test.skip=true'
如何在plugin中使用不同的configuration
以 mybatis-generator 为例
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>${MBG.version}</version>
<executions>
<!-- 这是默认配置 -->
<configuration>
<configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
<execution>
<!-- 运行方式 -->
<!-- mvn mybatis-generator:generate@gen_old -->
<id>gen_old</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<configurationFile>${basedir}/src/main/resources/generator_old/generatorConfig.xml
</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
使用默认配置
mvn mybatis-generator
使用自定义配置
mvn mybatis-generator:generate@gen_old
maven 编译优化
导入第三方jar
可以在compile.plugin添加extdirs
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<skip>${plugin.compile.skip}</skip>
<compilerArguments>
<extdirs>${project.basedir}/src/main/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>