Gradle忽略了内部关系存储库

时间:2018-12-19 15:37:46

标签: java linux gradle

我有一个非常简单的java项目,并且正在使用gradle进行构建。 我有Linux RedHat服务器(无法访问互联网),但是该服务器可以访问内部关系存储库,其中存在所有必需的依赖项。

这是build.gradle文件:

buildscript {
    ext {
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
    id 'com.github.jacobono.jaxb' version '1.3.5' // this is 14 line
}

repositories {
    maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}

subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'
    apply plugin: 'eclipse'
    apply plugin: 'maven'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8

    dependencyManagement {
        imports {
            mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
        }
    }

    buildscript {
        repositories {
            maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
        }
    }
    repositories {
        maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
    }
}

allprojects {
    buildscript {
        repositories {
            maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
        }
    }
}

设置文件settings.gradle

include 'api'

project(":api").name = "api"

这个项目有1个子模块api filder。 api build.gradle文件:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

apply plugin: 'com.github.jacobono.jaxb'

springBoot {
    buildInfo()
}

group = 'com.example'
version = '1.0.0'
sourceCompatibility = 1.8

repositories {
    maven { url "https://nexus.com.mysite/nexus/content/repositories/mirror/" }
}

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
}

springBoot {
    mainClassName = 'com.example.TestApplication'
}

在我的linux服务器上,我有: -Java 8 -摇篮4.5.1 -mvn 3.5.6

当我在项目的根文件夹中运行gradle clean时,5-10分钟后我收到错误消息:

FAILURE: Build failed with an exception.

* Where:
Build file '/my-proj/build.gradle' line: 14

* What went wrong:
Plugin [id: 'com.github.jacobono.jaxb', version: '1.3.5'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.github.jacobono.jaxb:com.github.jacobono.jaxb.gradle.plugin:1.3.5')
  Searched in the following repositories:
    Gradle Central Plugin Repository

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 10m 3s

由于某种原因,此错误中没有关于我的nexus存储库的信息...我假设它甚至都没有尝试过该存储库。问题是为什么...?

任何帮助我都会很高兴...也许我在某个地方的build.gradle文件中出错了...

p.s。在我的本地PC上(我可以访问Internet,并且可以访问此存储库,所有文件都可以正常工作)

1 个答案:

答案 0 :(得分:1)

默认情况下,插件是从Gradle插件门户解析的。如果要从其他来源解析它们,则应将配置添加到settings.gradle文件。

示例:

pluginManagement {
    repositories {
        maven {
            url '../maven-repo'
        }
        gradlePluginPortal()
        ivy {
            url '../ivy-repo'
        }
    }
}

检查docs以获得详细信息。