我正在尝试在脱机计算机上构建项目(这是必需的)。我已经创建了本地Maven存储库(它只是具有适当结构的文件夹)并成功构建了所有其他内容。

我采用以下方式:

1)运行gradle installl(此Maven插件的目标)

然后手动检查错误。如果我发现找不到某些库,则

2)我将其作为行家坐标,并从我的机器中手动复制到该机器中。

除Antlr之外,它均有效。我收到以下消息:

>gradle install
:generateGrammarSource

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':antlr'.
> Could not download antlr4.jar (org.antlr:antlr4:4.5)
   > Could not get resource 'http://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.jar'
      > Could not HEAD 'http://repo.maven.apache.org/maven2/org/antlr/antlr4/4.5/antlr4-4.5.jar'.
         > Connection to http://repo.maven.apache.org refused

错误消息与往常一样,但是这次将jar放入本地Maven存储库中无济于事。

如何克服?如何配置Antlr从本地Maven存储库中用餐?

更新

文件存在于
 MYHOME\.gradle\caches\modules-2\files-2.1\org.antlr\antlr4\4.5\af4a530e3cd7fa03636645d8077145eefac12907\antlr4-4.5.jar

和在
MYHOME\.m2\repository\org\antlr\antlr4\4.5\antlr4-4.5.jar

在行家的情况下,也存在伴随文件。

更新2

注意它说
Could not resolve all dependencies for configuration ':antlr'.

和Antlr依赖项由添加
antlr "org.antlr:antlr4:4.5" // use ANTLR version 4

即不是compile也不是testCompile。可能这是线索吗?可能是专门针对antlr配置配置存储库的方法吗?

更新3

在那些我成功解决的案例中,我正在写:
Could not resolve all dependencies for configuration ':compile'.
> Could not resolve net.coobird:thumbnailator:0.4.8.
  Required by:
      com.cireca.overlaywidget:OverlayWidget:1.0-SNAPSHOT
   > Could not resolve net.coobird:thumbnailator:0.4.8.
      > Could not get resource 'https://repo1.maven.org/maven2/net/coobird/thumbnailator/0.4.8/thumbnailator-0.4.8.pom'.
         > Could not GET 'https://repo1.maven.org/maven2/net/coobird/thumbnailator/0.4.8/thumbnailator-0.4.8.pom'.
            > Connection to https://repo1.maven.org refused

更新4

奇怪的事情。我注意到我的配置看起来很多余:
repositories {
    maven { url "http://repo.maven.apache.org/maven2" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "http://maven-eclipse.github.io/maven" }
    mavenLocal()
    flatDir {
        dirs 'lib'
    }

    maven { url "http://repo.maven.apache.org/maven2" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "http://maven-eclipse.github.io/maven" }

}

我将其更改为
repositories {
    mavenLocal()
    flatDir {
        dirs 'lib'
    }

    maven { url "http://repo.maven.apache.org/maven2" }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    maven { url "http://maven-eclipse.github.io/maven" }

}

之后,它开始要求不同的图书馆。首先它声称
org.antlr:antlr4-runtime:4.5

我喂饱了,但是后来声称
org.antlr:antlr-runtime:3.5.2

而且我无法喂食(相同情况)。

最佳答案

Maven按照您的settings.xml中指定的方式联系存储库。如果要避免使用外部存储库,则需要镜像所有内容。

实际上,在未连接互联网的环境中工作的最佳方法是设置自己的Nexus / Artifactory。填充存储库以供脱机使用的最简单方法是将其一次连接到Internet,然后构建所有内容并断开连接。然后,您拥有与您相关的所有内容的本地副本。

10-02 02:05
查看更多