1

我有一个项目,其中 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' 会生成以下错误消息:

[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 上。

4

1 回答 1

2

据我了解,您只需更改 pom 文件以在构建下包含此插件。

此处的 Maven 中央存储库中提供了相同的插件。

    <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版本更改

于 2013-08-14T21:02:50.760 回答