我正在尝试设置离线 Gradle 构建。
理想情况下,我希望将我所有的项目依赖项放在一个任意的 Maven 存储库中,如下所示:
repositories {
maven {
url 'file://PATH/TO/REPO'
}
}
但是,上述操作在全新的 Gradle 安装(无 ~/.gradle 缓存)中失败,如下所示:
* What went wrong
Plugin [id: PLUGINID, version: PLUGINVERSION] was not found in any of the
following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolvee plugin artifact 'PLUGINID:PLUGINNAME:PLUGINVERSION')
Searched in the following repositories:
Gradle Central Plugin Repository
我尝试了几种不同的方法来指定存储库,包括:
用“flatDir { dir '/PATH/TO/REPO' }”替换“url...”。
将所有依赖项复制到 ~/.m2 并调用 mavenLocal() 作为存储库。
要将依赖项从 ~/.gradle/caches/modules-2/files-2.1/ 复制到我的“离线”存储库中,我尝试过:
直接复制/粘贴
Gradle 任务将结构转换为:
task cacheLocal(type: Copy) {
from new File(gradle.gradleUserHomeDir, 'caches/modules-2/files-2.1')
into '/PATH/TO/REPO'
eachFile {
List<String> parts = it.path.split('/')
it.path = (parts[0] + '/' + parts[1]).replace('.','/') + '/' + parts[2] + '/' + parts[4]
}
includeEmptyDirs = false
}
其他事情:
使用“--offline”运行没有区别。
如果 ~/.gradle 已经存在,则构建成功,否则失败。
我的插件块(上面的错误语句将命中第一个非 Gradle 核心插件,因此在本例中为 protobuf):
plugins {
id "com.google.protobuf" version "0.8.6"
id "nebula.ospackage" version "4.9.3"
id "java"
id "eclipse"
}
这超出了我的理解,任何帮助将不胜感激!
大话西游666
相关分类