Gradle 离线使用插件和依赖项

Gradle use plugins and dependencies offline

为了演示,我需要离线编译一个 Gradle 项目。 但是到目前为止,我为使依赖项和插件脱机工作所做的一切尝试都失败了。 离线使用 Gradle 并使插件和依赖项之前可用的推荐方法是什么?

这是我目前在线使用的实现:

buildscript {    
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
    }    
}

repositories {
    mavenCentral()
}
dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("junit:junit")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    testCompile("org.springframework.boot:spring-boot-starter-test")
}

您应该能够使用“--offline”选项离线构建(例如,没有可用的网络),如下所述:https://docs.gradle.org/current/userguide/command_line_interface.html#sec:command_line_execution_options

我刚刚尝试过,使用 Gradle v4.9 效果很好:

  • clean/build 项目,
  • 关闭网络,
  • 执行 './gradlew clean build --offline' => 构建成功

您是否尝试使用此选项进行构建?或者您尝试过什么其他解决方案?