Giter Site home page Giter Site logo

Comments (6)

ben-manes avatar ben-manes commented on June 8, 2024

Since we defer to Gradle to resolve the dependency, maybe it is non-deterministic due to caching and repository ordering? I usually add --refresh-dependencies so I wonder if that would make it more consistent for you, as it forces it to bypass the cache?

from gradle-versions-plugin.

dalewking avatar dalewking commented on June 8, 2024

I don't think it is gradle, because it is not a question of versions (at least for the first part). It is getting the correct versions for current and milestone versions, it is the projectUrl

from gradle-versions-plugin.

ben-manes avatar ben-manes commented on June 8, 2024

We actually get that from Gradle as well,

private fun resolveProjectUrl(id: ModuleVersionIdentifier): String? {
return try {
val resolutionResult =
project.dependencies
.createArtifactResolutionQuery()
.forComponents(DefaultModuleComponentIdentifier.newId(id))
.withArtifacts(MavenModule::class.java, MavenPomArtifact::class.java)
.execute()
// size is 0 for gradle plugins, 1 for normal dependencies
for (result in resolutionResult.resolvedComponents) {
// size should always be 1
for (artifact in result.getArtifacts(MavenPomArtifact::class.java)) {
if (artifact is ResolvedArtifactResult) {
val file = artifact.file
project.logger.info("Pom file for $id is $file")
var url = getUrlFromPom(file)
if (!url.isNullOrEmpty()) {
project.logger.info("Found url for $id: $url")
return url.trim()
} else {
val parent = getParentFromPom(file)
if (parent != null &&
"${parent.group.orEmpty()}:${parent.name}" != "org.sonatype.oss:oss-parent"
) {
url = getProjectUrl(parent)
if (!url.isNullOrEmpty()) {
return url.trim()
}
}
}
}
}
}
project.logger.info("Did not find url for $id")

from gradle-versions-plugin.

dalewking avatar dalewking commented on June 8, 2024

Could there be a race condition ambiguity here whether it uses resolvedCoordinate or originalCoordinate

  private fun getStatus(
    coordinates: Map<Coordinate.Key, Coordinate>,
    resolved: Set<ResolvedDependency>,
    unresolved: Set<UnresolvedDependency>,
  ): Set<DependencyStatus> {
    val result = hashSetOf<DependencyStatus>()
    for (dependency in resolved) {
      val resolvedCoordinate = Coordinate.from(dependency.module.id)
      val originalCoordinate = coordinates[resolvedCoordinate.key]
      val coord = originalCoordinate ?: resolvedCoordinate
      val projectUrl = getProjectUrl(dependency.module.id)
      result.add(DependencyStatus(coord, resolvedCoordinate.version, projectUrl))
    }

from gradle-versions-plugin.

ben-manes avatar ben-manes commented on June 8, 2024

I believe the only shared mutable state in this plugin is the projectUrls cache, which uses a precursor idiom to computeIfAbsent as that was written in pre-Java 8 Groovy. The rest is thread local state, so assuming that the configuration is not modified at runtime it should be stable as computations passed down between methods. That's not always true as much of Gradle is mutable and allowed to change, e.g. #98 takes advantage of that. So your idea makes a lot of sense, but I don't think we could do much at the plugin level?

from gradle-versions-plugin.

dalewking avatar dalewking commented on June 8, 2024

All i am asking is to do a little debugging to see where it is happening. For example, putting some printlns to see if which version number is being used to call getProjectUrl and see if that is changing.

from gradle-versions-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.