开发者

How to specify a maven repository

I am taking over a project left by previous colleague. The project is mavenized and I'm having a hard time building it. There is a inside block, which generates error when I ran mvn install. The error shows that plugin cannot be found in maven central repo. I checked and it's not there. I happened to find another internal repository that has the plugin jar file. So outside the block, I specified a to point at that internal repo. However, when I ran mvn install again, it still goes to maven central repo to look for the plugin. How do I make it look for the jar file at the right repo? I thought by specifying the list, it would automatically check that list? Other than the repo I added, there was no repository list set up previously.

The missing plugin that I can't get it to work is like this:

    <build>
        <plugins>
            <plugin>
            <groupId>com.totsp.gwt</groupId>
            <artifactId>maven-googlewebtoolkit2-plugin</artifactId>
           <version>2.0-SNAPSHOT</version>
            <configuration>
                <gwtVersion>2.0.0</gwtVersion>
                <style>OBF</style>
                <gen>target/gwtgen</gen>
                <runTarget>/</runTarget>
                <extraJvmArgs>-Xmx512m</extraJvmArgs>
                <port>8088</port>
                <useHtmlUnit>true</useHtmlUnit>
                <htmlUnitBrowsers>
                    <param>FF3</param>
                </htmlUnitBrowsers>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
       开发者_StackOverflow中文版 </plugin>
    </build>


Ok, now that you've provided the relevant part of your pom, I can say that you basically have two options here: either get the sources of the plugin and install it in your local repo or get the plugin from the maven repository of the project.

Option #1

Use a subversion client and get the sources of the plugin (version 2.0-SNAPSHOT is the current version) from the svn repository, build and install the plugin in your local repository. Here using the svn command line client:

$ svn co http://gwt-maven.googlecode.com/svn/trunk/maven-googlewebtoolkit2-plugin/ maven-googlewebtoolkit2-plugin
$ cd maven-googlewebtoolkit2-plugin
$ mvn install 

Note that this approach doesn't solve the portability issue (another developer would have to repeat the same steps) and I can't guarantee that you'll get exactly the same version of the code than the previous developer.

Option #2

Declare the Maven Repository of the project as a <pluginRepository> and change the version of the plugin (2.0-SNAPSHOT is not available). Something like this:

<pluginRepositories>
  <pluginRepository>
    <id>gwt-maven</id>
    <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo</url>
  </pluginRepository>
</pluginRepositories>
<build>
  <plugins>
    <plugin>
      <groupId>com.totsp.gwt</groupId>
      <artifactId>maven-googlewebtoolkit2-plugin</artifactId>
      <version>2.0-RC1</version>
      <configuration>
        <gwtVersion>2.0.0</gwtVersion>
        <style>OBF</style>
        <gen>target/gwtgen</gen>
        <runTarget>/</runTarget>
        <extraJvmArgs>-Xmx512m</extraJvmArgs>
        <port>8088</port>
        <useHtmlUnit>true</useHtmlUnit>
        <htmlUnitBrowsers>
          <param>FF3</param>
        </htmlUnitBrowsers>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>test</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

Again, I can't say anything about the changes between this version and the 2.0-SNAPSHOT the other developer was using.

Last but not least (but this might not be a top priority for you right now), this plugin has been deprecated and is replaced by the gwt-maven-plugin from Codehaus. On the long term, you should consider moving to the Codehaus plugin.


I believe that your colleague has the pluginRepository configured in his ${MAVEN_HOME}/conf/settings.xml. Check if you have a company-wide repos which you need to configure in your Maven.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜