简体   繁体   中英

How do I configure my maven settings.xml in order to use the minify-maven-plugin?

I have a project where the pom.xml makes use of the minify-maven-plugin . I couldn't find any documentation on how to configure the pluginRepository entry in my $M2_HOME/conf/settings.xml, so I took a wild guess and added this entry:

<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>

But when I run mvn minify:minify from my project directory I get:

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] ------------------------------------------------------------------------

Running `mvn -X minify:minify' generates this error message:

[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)

What am I getting wrong?

I'm using Maven 2.2. I added the egit plugin in case I needed it, since the minify-maven-plugin is on github.

Upto my understanding you have to only change the pom file to include this plugin under build.

The same plugin is available in 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>

Note : I have used the version 1.7 here , you can change as per your jdk version

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM