0

我尝试将 github 用作我在那里托管的项目的 maven 存储库,但我在让它工作时遇到了一些问题。首先,这是项目:

https://github.com/dwatrous/cache4guice

我创建了一个分支“mvn-repo”来保存 Maven 发布文件。我按照这个过程为该分支创建了 maven 文件:

http://blog.rueedlinger.ch/2012/09/use-github-as-maven-remote-repository/

我已经确认文件在那里。然后我将它添加到 pom.xml 中,用于使用 cache4guice 库的项目:

<repository>
    <id>com.github.cache4guice</id>
    <url>https://github.com/dwatrous/cache4guice/tree/mvn-repo</url>
    <!-- use snapshot version -->
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
</repository>

<dependency>
    <groupId>com.github</groupId>
    <artifactId>cache4guice</artifactId>
    <version>0.1</version>
</dependency>

构建时出现以下错误:

Downloading: https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.pom
Checksum validation failed, expected <!DOCTYPE but is 6ca9a53135148bf33e1b08aadc611b65489b4991 for https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.pom
Checksum validation failed, expected <!DOCTYPE but is 57e202c6b25139da08d065550ebd8c50d9f7d162 for https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.pom

Downloaded: https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.pom (38 KB at 2.7 KB/sec)
The POM for com.github:cache4guice:jar:0.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
Downloading: http://morphia.googlecode.com/svn/mavenrepo/com/github/cache4guice/0.1/cache4guice-0.1.jar

Downloading: https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.jar
Checksum validation failed, expected <!DOCTYPE but is 12bd0042aad0971621728f9ba3c048106ef8a84e for https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.jar
Checksum validation failed, expected <!DOCTYPE but is 1506b45c11f00ba484462660f61a83ac14620761 for https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.jar

Downloaded: https://github.com/dwatrous/cache4guice/tree/mvn-repo/com/github/cache4guice/0.1/cache4guice-0.1.jar (23 KB at 4.7 KB/sec)

最终是这样的:

COMPILATION ERROR : 
-------------------------------------------------------------
error: error reading C:\Users\watrous\.m2\repository\com\github\cache4guice\0.1\cache4guice-0.1.jar; error in opening zip file

我检查了一下,jar 文件似乎是伪造的。我无法使用 zip 实用程序打开它,并且大小比存储库中的稍大。

知道我哪里出错了,或者为什么文件 maven 得到了似乎是假的吗?

4

1 回答 1

2

原来这很简单。我只需要将存储库声明更改为引用raw.github.com,如下所示:

<repository>
    <id>com.github.cache4guice</id>
    <url>https://raw.github.com/dwatrous/cache4guice/mvn-repo</url>
    <!-- use snapshot version -->
    <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
    </snapshots>
</repository>

我仍然遇到校验和问题,但所有文件都正确下载并且我可以构建。

于 2013-05-23T16:08:46.470 回答