简体   繁体   English

Gradle 刷新快照依赖不起作用

[英]Gradle refresh snapshot dependencies does not work

The Stackoverflow contains some questions regarding this issue but unfortunately, nothing works for me. Stackoverflow 包含有关此问题的一些问题,但不幸的是,对我没有任何作用。 For example, I read this例如,我读了这个

My build.gradle looks like this:我的 build.gradle 看起来像这样:

plugins {
    id 'org.springframework.boot' version '2.3.3.RELEASE'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
    id 'java-library'
    id 'maven-publish'
    id 'net.linguica.maven-settings' version '0.5'
}

tasks.withType(Test) {
    testLogging {
        exceptionFormat "full"
        events "started", "skipped", "passed", "failed"
        showStandardStreams true
    }
}

sourceCompatibility = '11'
targetCompatibility = '11'

mavenSettings {
    userSettingsFileName project.getProperty('settingsXml')
}

configurations.all {
    resolutionStrategy {
        cacheDynamicVersionsFor 0, 'seconds'
        cacheChangingModulesFor 0, 'seconds'
    }
}


// This configuration is necessary for publishing spring boot jar
configurations {
    [apiElements, runtimeElements].each {
        it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) }
        it.outgoing.artifact(bootJar)
    }
}

group 'com.something.company'
version '1.0.0-SNAPSHOT'

repositories {
    maven {
        name 'nexus.aliter.com'
        url 'https://nexus.aliter.com/repository/cloud-maven/'
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            name 'nexus.aliter.com'
            if(project.version.endsWith('-SNAPSHOT')) {
                url 'https://nexus.repo.com/repository/maven-snapshots/'
            } else {
                url 'https://nexus.repo.com/repository/maven-releases/'
            }
        }
    }
}

springBoot {
    buildInfo()
}

test {
    useJUnitPlatform()
}

dependencies {
    implementation group: 'com.aliter.csp', name: 'security-lib', version: '1.0.0-SNAPSHOT'
    implementation group: 'com.aliter.csp', name: 'adapter-lib', version: '1.0.0-SNAPSHOT'
}

I tried this:我试过这个:

configurations.all {
    resolutionStrategy {
        cacheDynamicVersionsFor 0, 'seconds'
        cacheChangingModulesFor 0, 'seconds'
    }
}

and I tried keyword changing: true , I tried gradle clean build --refresh-dependencies and nothing works for me.我尝试了关键字更改: true ,我尝试了 gradle clean build --refresh-dependencies并且对我没有任何作用。 The gradle shows me that cannot find the snapshot dependencies. gradle 显示找不到快照依赖项。

We build the project through Jenkins, so in the matter of automation, it is necessary to not delete.gradle/cache every time.我们通过Jenkins来构建项目,所以在自动化的问题上,不能每次都delete.gradle/cache。 I am 100% percent sure that snapshot dependencies are available in the nexus repository.我 100% 确定在 nexus 存储库中可以使用快照依赖项。

Gradle version: 6.6.1 Gradle 版本:6.6.1

I found the solution, problem was that the nexus repository missed this maven-metadata.xml我找到了解决方案,问题是 nexus 存储库错过了这个 maven-metadata.xml

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM