New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mark Missing Local Artifacts as optional #23245
Changes from all commits
70d273b
5e88930
94689e2
d85ce80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* Copyright 2022 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.gradle.integtests.resolve | ||
|
||
import org.gradle.integtests.fixtures.AbstractIntegrationSpec | ||
import spock.lang.Issue | ||
|
||
@Issue("https://github.com/gradle/gradle/pull/23245") | ||
class ResolvePOMSpec extends AbstractIntegrationSpec { | ||
def "resolving a @pom artifact from an included build replacing an external library doesn't fail the build"() { | ||
given: | ||
def mainProjectDir = file("main-project") | ||
def includedLoggingProjectDir = file("included-logging") | ||
|
||
mainProjectDir.file("settings.gradle.kts").text = """ | ||
rootProject.name = "main-project" | ||
include("app") | ||
includeBuild("../included-logging") | ||
""" | ||
|
||
mainProjectDir.file("app/build.gradle.kts").text = """ | ||
plugins { | ||
application | ||
} | ||
|
||
dependencies { | ||
implementation("org.gradle.repro:lib@pom") | ||
} | ||
""" | ||
|
||
includedLoggingProjectDir.file("settings.gradle.kts").text = """ | ||
rootProject.name = "included-logging" | ||
include("lib") | ||
""" | ||
|
||
includedLoggingProjectDir.file("lib/build.gradle.kts").text = """ | ||
plugins { | ||
`java-library` | ||
} | ||
""" | ||
|
||
includedLoggingProjectDir.file("gradle.properties").text = """ | ||
group=org.gradle.repro | ||
version=0.1.0-SNAPSHOT | ||
""" | ||
|
||
executer.inDirectory(mainProjectDir) | ||
|
||
expect: | ||
succeeds "build" | ||
} | ||
|
||
def "getting the file for a @pom artifact from an included build replacing an external library doesn't fail the build"() { | ||
given: | ||
def mainProjectDir = file("main-project") | ||
def includedLoggingProjectDir = file("included-logging") | ||
|
||
mainProjectDir.file("settings.gradle.kts").text = """ | ||
rootProject.name = "main-project" | ||
include("app") | ||
includeBuild("../included-logging") | ||
""" | ||
|
||
mainProjectDir.file("app/build.gradle.kts").text = """ | ||
plugins { | ||
application | ||
} | ||
|
||
dependencies { | ||
implementation("org.gradle.repro:lib@pom") | ||
} | ||
|
||
tasks.register("resolve") { | ||
doLast { | ||
val c: Configuration = configurations.getByName("compileClasspath") | ||
c.getResolvedConfiguration() | ||
.getLenientConfiguration() | ||
.getAllModuleDependencies() | ||
.map { it.getAllModuleArtifacts() } | ||
.forEach { mas -> | ||
mas.forEach { a -> | ||
println(a.getFile()) | ||
} | ||
} | ||
} | ||
} | ||
""" | ||
|
||
includedLoggingProjectDir.file("settings.gradle.kts").text = """ | ||
rootProject.name = "included-logging" | ||
include("lib") | ||
""" | ||
|
||
includedLoggingProjectDir.file("lib/build.gradle.kts").text = """ | ||
plugins { | ||
`java-library` | ||
} | ||
""" | ||
|
||
includedLoggingProjectDir.file("gradle.properties").text = """ | ||
group=org.gradle.repro | ||
version=0.1.0-SNAPSHOT | ||
""" | ||
|
||
executer.inDirectory(mainProjectDir) | ||
|
||
expect: | ||
succeeds "resolve" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,12 @@ public static ResolvedVariant create(@Nullable VariantResolveMetadata.Identifier | |
|
||
private static Supplier<ResolvedArtifactSet> supplyResolvedArtifactSet(DisplayName displayName, AttributeContainerInternal attributes, CapabilitiesMetadata capabilities, Supplier<Collection<? extends ResolvableArtifact>> artifactsSupplier) { | ||
return () -> { | ||
Collection<? extends ResolvableArtifact> artifacts = artifactsSupplier.get(); | ||
Collection<? extends ResolvableArtifact> artifacts; | ||
try { | ||
artifacts = artifactsSupplier.get(); | ||
} catch (Exception e) { | ||
return EMPTY; | ||
} | ||
if (artifacts.isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there was an easy way to pass information about whether we are resolving leniently or strictly to the Alternately, if we could change the As it is now, passing this information all the way into this |
||
return EMPTY; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant to link to the issue here?