|
19 | 19 |
|
20 | 20 | import groovy.transform.ToString |
21 | 21 | import groovy.transform.TupleConstructor |
| 22 | +import org.gradle.internal.build.BuildState |
22 | 23 |
|
23 | 24 | import javax.inject.Inject |
24 | 25 |
|
@@ -218,7 +219,7 @@ class AbstractOrtDependencyTreePlugin<T> implements Plugin<T> { |
218 | 219 |
|
219 | 220 | try { |
220 | 221 | resolvedArtifacts = configuration.resolvedConfiguration.lenientConfiguration |
221 | | - .getArtifacts(Specs.SATISFIES_ALL) |
| 222 | + .getArtifacts() |
222 | 223 | } catch (ResolveException e) { |
223 | 224 | project.logger.info("Artifacts for configuration '${configuration.name}' could not be " + |
224 | 225 | "resolved, therefore no information about artifact classifiers and extensions is " + |
@@ -387,7 +388,7 @@ class AbstractOrtDependencyTreePlugin<T> implements Plugin<T> { |
387 | 388 | return new OrtDependencyImpl(id.group, id.module, id.version, classifier, extension, [] as Set, dependencies, |
388 | 389 | error, warning, pomFile, null) |
389 | 390 | } else if (id instanceof ProjectComponentIdentifier) { |
390 | | - if (id.build.isCurrentBuild() || !project.gradle.gradleVersion.isAtLeastVersion(7, 2)) { |
| 391 | + if (isCurrentBuild(id.build, project) || !project.gradle.gradleVersion.isAtLeastVersion(7, 2)) { |
391 | 392 | def dependencyProject = project.rootProject.findProject(id.projectPath) |
392 | 393 | return new OrtDependencyImpl(groupId: dependencyProject.group.toString(), |
393 | 394 | artifactId: dependencyProject.name, version: dependencyProject.version.toString(), |
@@ -416,6 +417,22 @@ class AbstractOrtDependencyTreePlugin<T> implements Plugin<T> { |
416 | 417 | } |
417 | 418 | } |
418 | 419 |
|
| 420 | + private static boolean isCurrentBuild(BuildIdentifier buildIdentifier, Project project) { |
| 421 | + if (project.gradle.hasProperty('buildPath')) { |
| 422 | + // Gradle 9.1 and above |
| 423 | + return buildIdentifier.buildPath == project.gradle.buildPath |
| 424 | + } |
| 425 | + |
| 426 | + if (buildIdentifier.hasProperty('currentBuild')) { |
| 427 | + // Gradle 8 |
| 428 | + return buildIdentifier.currentBuild as boolean |
| 429 | + } |
| 430 | + |
| 431 | + // Gradle 9.0, using internal API |
| 432 | + BuildIdentifier projectBuildIdentifier = project.services.get(BuildState).buildIdentifier |
| 433 | + return buildIdentifier.buildPath == projectBuildIdentifier.buildPath |
| 434 | + } |
| 435 | + |
419 | 436 | private static boolean canBeResolved(Configuration configuration) { |
420 | 437 | // The canBeResolved property is available since Gradle 3.3. |
421 | 438 | boolean canBeResolved = !configuration.hasProperty('canBeResolved') || configuration.canBeResolved |
@@ -489,7 +506,7 @@ class AbstractOrtDependencyTreePlugin<T> implements Plugin<T> { |
489 | 506 | if (id instanceof ModuleComponentIdentifier) { |
490 | 507 | return toIdentifier(id.group, id.module, id.version) |
491 | 508 | } else if (id instanceof ProjectComponentIdentifier) { |
492 | | - if (id.build.currentBuild || !project.gradle.gradleVersion.isAtLeastVersion(7, 2)) { |
| 509 | + if (isCurrentBuild(id.build, project) || !project.gradle.gradleVersion.isAtLeastVersion(7, 2)) { |
493 | 510 | def dependencyProject = project.rootProject.findProject(id.projectPath) |
494 | 511 | return toIdentifier(dependencyProject.group.toString(), dependencyProject.name, |
495 | 512 | dependencyProject.version.toString()) |
|
0 commit comments