Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
678 views
in Technique[技术] by (71.8m points)

java - Gradle refresh snapshot dependencies does not work

The Stackoverflow contains some questions regarding this issue but unfortunately, nothing works for me. For example, I read this

My build.gradle looks like this:

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. The gradle shows me that cannot find the snapshot dependencies.

We build the project through Jenkins, so in the matter of automation, it is necessary to not delete .gradle/cache every time. I am 100% percent sure that snapshot dependencies are available in the nexus repository.

Gradle version: 6.6.1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I found the solution, problem was that the nexus repository missed this maven-metadata.xml

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...