我有一个pom.xml使用minify-maven-plugin的项目。我无法找到有关如何在我的$ M2_HOME / conf / settings.xml中配置pluginRepository条目的任何文档,所以我做了一个疯狂的猜测并添加了这个条目:
<pluginRepository>
<id>minify-maven-plugin-repo</id>
<name>minify-maven-plugin repository</name>
<url>https://github.com/samaxes/minify-maven-plugin</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
但是当我从项目目录中运行mvn minify:minify
时,我得到:
C:\Users\J1NDH02\work\webui-war>mvn minify:minify
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'minify'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.apache.maven.plugins: checking for updates from minify-maven-plugin-r
epo
[INFO] org.codehaus.mojo: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from minify-maven-plugin-repo
[INFO] artifact org.apache.maven.plugins:maven-minify-plugin: checking for updat
es from central
[INFO] artifact org.apache.maven.plugins:maven-minify-plugin: checking for updat
es from minify-maven-plugin-repo
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-minify-plugin' does not exist
or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Wed Aug 14 15:23:04 CDT 2013
[INFO] Final Memory: 36M/308M
[INFO] ------------------------------------------------------------------------
运行`mvn -X minify:minify&#39;生成此错误消息:
[INFO] Searching repository for plugin with prefix: 'minify'.
[DEBUG] Loading plugin prefixes from group: org.apache.maven.plugins
[DEBUG] Loading plugin prefixes from group: org.codehaus.mojo
[DEBUG] maven-minify-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the latest version
org.apache.maven.plugins:maven-minify-plugin:pom:LATEST
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-minify-plugin:pom:LATEST
[DEBUG] maven-minify-plugin: using locally installed snapshot
[DEBUG] Artifact not found - using stub model: Unable to determine the release version
org.apache.maven.plugins:maven-minify-plugin:pom:RELEASE
[DEBUG] Using defaults for missing POM org.apache.maven.plugins:maven-minify-plugin:pom:RELEASE
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-minify-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: The plugin 'org.apache.maven.plugins:maven-minify-plugin' does not exist or no valid version could be found
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin(DefaultLifecycleExecutor.java:1569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.getMojoDescriptor(DefaultLifecycleExecutor.java:1851)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.segmentTaskListByAggregationNeeds(DefaultLifecycleExecutor.java:462)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:175)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我出错了什么?
我正在使用Maven 2.2。我添加了egit插件,以防我需要它,因为minify-maven-plugin在github上。
答案 0 :(得分:2)
根据我的理解,你必须只更改pom文件以在build下包含这个插件。
Maven central repo here中提供了相同的插件。
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>default-minify</id>
<phase>process-resources</phase>
<configuration></configuration>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
</plugin>
注意:我在这里使用的是1.7版本,您可以根据您的jdk版本进行更改