微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Gradle 刷新快照依赖项不起作用

如何解决Gradle 刷新快照依赖项不起作用

Stackoverflow 包含一些关于这个问题的问题,但不幸的是,没有任何东西对我有用。例如,我读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'
}

我试过了:

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

并且我尝试了关键字更改:true,我尝试了gradle clean build --refresh-dependencies,但没有任何效果我有用。 gradle 显示我找不到快照依赖项。

我们是通过Jenkins来构建项目的,所以在自动化方面,不要每次都删除.gradle/cache。我 100% 确定快照依赖项在 nexus 存储库中可用。

Gradle 版本:6.6.1

解决方法

我找到了解决方案,问题是nexus存储库错过了这个maven-metadata.xml

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。