Maven failure to find codehaus artifact org.codehaus:codehaus-parent

痞子三分冷 提交于 2019-12-08 07:04:50

问题


So codehaus shut down (over the weekend, apparently): https://www.codehaus.org/

Now it says here that "Maven: All repositories are mirrored into Central, and our Nexus is hosted by Sonatype". If I am reading this correctly, this means that it should continue to work (and because Central is the default repository, I shouldn't even have any changes to make).

Yet I am having trouble with a Maven project that used to compile (before the shutdown), but now fails:

[INFO] Error building POM (may not be this project's POM).

Project ID: org.codehaus.groovy:groovy-eclipse-compiler:maven-plugin:2.9.1-01
Reason: Cannot find parent: org.codehaus:codehaus-parent for project: org.codehaus.groovy:groovy-eclipse-compiler:maven-plugin:2.9.1-01 for project org.codehaus.groovy:groovy-eclipse-compiler:maven-plugin:2.9.1-01

Here's a trimmed-down version of my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.hp</groupId>
    <artifactId>device-state-service</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>device-state-service</name>

    <properties>
        <spring.version>3.2.0.RELEASE</spring.version>
        <groovy-all.version>2.3.7</groovy-all.version>
        <spock-core.version>0.7-groovy-2.0</spock-core.version>
        <lombok.version>1.12.2</lombok.version>
...
    </properties>

    <dependencies>
...

        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${groovy-all.version}</version>
        </dependency>
...
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
...
        <dependency>
            <groupId>org.spockframework</groupId>
            <artifactId>spock-core</artifactId>
            <version>${spock-core.version}</version>
            <scope>test</scope>
        </dependency>
...
        <dependency>
            <groupId>org.codehaus.groovy.modules.http-builder</groupId>
            <artifactId>http-builder</artifactId>
            <version>0.7</version>
            <scope>test</scope>
        </dependency>
...
    </dependencies>

    <build>
        <finalName>dss</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <compilerId>groovy-eclipse-compiler</compilerId>
                    <verbose>false</verbose>
                    <compilerArguments>
                        <javaAgentClass>lombok.core.Agent</javaAgentClass>
                    </compilerArguments>
                    <fork>true</fork>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-compiler</artifactId>
                        <version>2.9.1-01</version>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-eclipse-batch</artifactId>
                        <version>2.3.7-01</version>
                    </dependency>
                    <dependency>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
...
        </plugins>
    </build>    
        <profiles>
        <profile>
            <id>dss</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>deliverable</name>
                    <value>dss</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>rpm-maven-plugin</artifactId>
                        <version>2.1-alpha-1</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>rpm</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            ...
                            <name>${deliverable}</name>
                            <projversion>${pom.version}</projversion>
                            <release>${BUILD_NUMBER}</release>
                            <description>Search: RPM package</description>
                            <mappings>
                                <mapping>
                                    <directory>${tomcatInstallationDir}</directory>
                                    <filemode>755</filemode>
                                    <username>tomcat</username>
                                    <groupname>tomcat</groupname>
                                    <sources>
                                        <source>
                                            <location>../Tomcat/</location>
                                        </source>
                                    </sources>
                                </mapping>
                                <mapping>
                                    <directory>${tomcatInstallationDir}/webapps</directory>
                                    <filemode>755</filemode>
                                    <username>tomcat</username>
                                    <groupname>tomcat</groupname>
                                    <sources>
                                        <source>
                                            <location>target/${deliverable}.war
                                            </location>
                                            <destination>${deliverable}.war</destination>
                                        </source>
                                    </sources>
                                </mapping>
                            </mappings>
                            <requires>
                                <require>palm-jre &gt;= 1.6.0_27-fcs</require>
                            </requires>
                            <prefix>${tomcatInstallationDir}</prefix>
                            <preinstallScriptlet>
                                <scriptFile>../PlatformEngine/rpm_scripts/pre_install.sh</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                            </preinstallScriptlet>
                            <postinstallScriptlet>
                                <scriptFile>../PlatformEngine/rpm_scripts/post_install.sh</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                            </postinstallScriptlet>
                            <preremoveScriptlet>
                                <scriptFile>../PlatformEngine/rpm_scripts/pre_uninstall.sh</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                            </preremoveScriptlet>
                            <postremoveScriptlet>
                                <scriptFile>../PlatformEngine/rpm_scripts/post_uninstall.sh</scriptFile>
                                <fileEncoding>utf-8</fileEncoding>
                            </postremoveScriptlet>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

Now, in my .m2 directory I find for the groovy-all project a pom/sha1, and a jar file. But for groovy-eclipse-compiler, I see the pom/sha1, but no jar file.

Am I doing something wrong? Did something in the Codehaus migration itself get screwed up somehow? Or (worse) both?


回答1:


The maven artifacts are in central for a long time already, there is no migration that could have been screwed up for those.

Since I am no maven expert I can give you only what I assume is the cause. Looking at the pom for version 2.9.1-01 of the groovy-eclipse-compiler I see

<repositories>
    <repository>
        <id>codehaus.org</id>
        <url>http://repository.codehaus.org</url>
    </repository>
</repositories>

ans my assumption is, that this will cause maven to look in that repository, which does not exist anymore. If that is true, then my suggestion for a solution would be to manually install the artifacts (they are all on maven central) or to use a different tool like gradle (though that might be out of scope for you) to do the build.

EDIT: I have been told that you could change your settings.xml to fix repository configurations with a pattern like this:

<repositories>
    <repository>
        <id>codehaus.org</id>
        <url>http://nexus.codehaus.org/<some suburl></url>
    </repository>
</repositories>

Using http://mvnrepository.com/artifact for example might then work, but I have not tested this.




回答2:


The artifact you are referencing to:

org.codehaus.groovy:groovy-eclipse-compiler:maven-plugin:2.9.1-01

if this isn't being found by your build than simply your configuration is wrong. Either network/proxy issues etc. (see your settings.xml) You can search this artifact in Maven central via: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.codehaus.groovy%22%20AND%20a%3A%22groovy-eclipse-compiler%22

Apart from that adding supplemental repositories this does not help. Furthermore adding default's in a Maven pom like this:

  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
  </resources>
  <testResources>
    <testResource>
      <directory>src/test/resources</directory>
    </testResource>
  </testResources>

does not make sense either, cause these are the defaults. What i stumbled over as well is that you are defining things like the encoding:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>

First it is good to define the version of plugins like this (but you should use uptodate versions) but you should not define the encoding in every plugin. For such purposes a property exist:

<project>
  ...
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  ...
</project>

by using the above you don't need to give the encoding for every plugin, cause the plugins like maven-resources-plugin, maven-compiler-plugin etc. define a default.

A word about the codehaus migration. This means only the services they have offered for developers are shutting down but not the content which already is part for Maven central.

I would recommend to install a repository manager in your own infrastructure.



来源:https://stackoverflow.com/questions/30314301/maven-failure-to-find-codehaus-artifact-org-codehauscodehaus-parent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!