Skip to content

Commit

Permalink
Revert "Allow publication artifacts to be defined as files through pr…
Browse files Browse the repository at this point in the history
…oviders (#11329)"

This reverts commit a4b79f3.
  • Loading branch information
jjohannes committed Nov 12, 2019
1 parent a4b79f3 commit ab9742f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 53 deletions.
Expand Up @@ -25,17 +25,12 @@ class IvyPublishArtifactCustomizationIntegTest extends AbstractIvyPublishIntegTe
void "can publish custom artifacts"() {
given:
createBuildScripts("""
file("customFile.foo") << 'some foo'
file("customFile.bar") << 'some bar'
publications {
ivy(IvyPublication) {
artifact "customFile.txt"
artifact customDocsTask.outputFile
artifact regularFileTask.outputFile
artifact customJar
artifact provider { file("customFile.foo") }
artifact provider { "customFile.bar" }
}
}
""", """
Expand All @@ -51,21 +46,19 @@ class IvyPublishArtifactCustomizationIntegTest extends AbstractIvyPublishIntegTe

then:
module.assertPublished()
module.assertArtifactsPublished("ivy-2.4.xml", "ivyPublish-2.4.txt", "ivyPublish-2.4.foo", "ivyPublish-2.4.bar", "ivyPublish-2.4.html", "ivyPublish-2.4.reg", "ivyPublish-2.4.jar")
module.assertArtifactsPublished("ivy-2.4.xml", "ivyPublish-2.4.txt", "ivyPublish-2.4.html", "ivyPublish-2.4.reg", "ivyPublish-2.4.jar")

and:
def ivy = module.parsedIvy
ivy.expectArtifact('ivyPublish', 'txt').hasType("txt").hasConf(null)
ivy.expectArtifact('ivyPublish', 'html').hasType("html").hasConf(null)
ivy.expectArtifact('ivyPublish', 'jar').hasType("jar").hasConf(null)
ivy.expectArtifact('ivyPublish', 'reg').hasType("reg").hasConf(null)
ivy.expectArtifact('ivyPublish', 'foo').hasType("foo").hasConf(null)
ivy.expectArtifact('ivyPublish', 'bar').hasType("bar").hasConf(null)

and:
resolveArtifacts(module) {
withoutModuleMetadata {
expectFiles "ivyPublish-2.4.html", "ivyPublish-2.4.jar", "ivyPublish-2.4.reg", "ivyPublish-2.4.txt", "ivyPublish-2.4.foo", "ivyPublish-2.4.bar"
expectFiles "ivyPublish-2.4.html", "ivyPublish-2.4.jar", "ivyPublish-2.4.reg", "ivyPublish-2.4.txt"
}
withModuleMetadata {
noComponentPublished()
Expand Down
Expand Up @@ -18,7 +18,6 @@

import org.gradle.api.artifacts.PublishArtifact;
import org.gradle.api.internal.file.FileResolver;
import org.gradle.api.internal.provider.ProviderInternal;
import org.gradle.api.internal.tasks.TaskDependencyContainer;
import org.gradle.api.publish.ivy.IvyArtifact;
import org.gradle.api.publish.ivy.internal.publisher.IvyPublicationIdentity;
Expand Down Expand Up @@ -105,7 +104,7 @@ private FileNotationConverter(FileResolver fileResolver) {
public void convert(Object notation, NotationConvertResult<? super IvyArtifact> result) throws TypeConversionException {
File file = fileResolverNotationParser.parseNotation(notation);
IvyArtifact ivyArtifact = instantiator.newInstance(FileBasedIvyArtifact.class, file, publicationIdentity);
if (dependsOnTask(notation)) {
if (notation instanceof TaskDependencyContainer) {
ivyArtifact.builtBy(notation);
}
result.converted(ivyArtifact);
Expand All @@ -117,14 +116,6 @@ public void describe(DiagnosticsVisitor visitor) {
}
}

private boolean dependsOnTask(Object notation) {
if (notation instanceof ProviderInternal) {
ProviderInternal<?> provider = (ProviderInternal<?>) notation;
return provider.isContentProducedByTask() || provider.isValueProducedByTask();
}
return notation instanceof TaskDependencyContainer;
}

private class IvyArtifactMapNotationConverter extends MapNotationConverter<IvyArtifact> {
private final NotationParser<Object, IvyArtifact> sourceNotationParser;

Expand Down
Expand Up @@ -23,16 +23,11 @@ class MavenPublishArtifactCustomizationIntegTest extends AbstractMavenPublishInt
def "can attach custom artifacts"() {
given:
createBuildScripts("""
file("customFile.foo") << 'some foo'
file("customFile.bar") << 'some bar'
publications {
mavenCustom(MavenPublication) {
artifact "customFile.txt"
artifact customJar
artifact regularFileTask.outputFile
artifact provider { file("customFile.foo") }
artifact provider { "customFile.bar" }
}
}
""")
Expand All @@ -42,7 +37,7 @@ class MavenPublishArtifactCustomizationIntegTest extends AbstractMavenPublishInt
then:
def module = mavenRepo.module("group", "projectText", "1.0")
module.assertPublished()
module.assertArtifactsPublished("projectText-1.0.pom", "projectText-1.0.txt", "projectText-1.0.foo", "projectText-1.0.bar", "projectText-1.0-customjar.jar", "projectText-1.0.reg")
module.assertArtifactsPublished("projectText-1.0.pom", "projectText-1.0.txt", "projectText-1.0-customjar.jar", "projectText-1.0.reg")

and:
resolveArtifacts(module) {
Expand All @@ -54,24 +49,6 @@ class MavenPublishArtifactCustomizationIntegTest extends AbstractMavenPublishInt
expectFiles "projectText-1.0.txt"
}
}
resolveArtifacts(module) {
ext = 'foo'
withModuleMetadata {
noComponentPublished()
}
withoutModuleMetadata {
expectFiles "projectText-1.0.foo"
}
}
resolveArtifacts(module) {
ext = 'bar'
withModuleMetadata {
noComponentPublished()
}
withoutModuleMetadata {
expectFiles "projectText-1.0.bar"
}
}
resolveArtifacts(module) {
ext = 'reg'
withModuleMetadata {
Expand Down
Expand Up @@ -18,7 +18,6 @@

import org.gradle.api.artifacts.PublishArtifact;
import org.gradle.api.internal.file.FileResolver;
import org.gradle.api.internal.provider.ProviderInternal;
import org.gradle.api.internal.tasks.TaskDependencyContainer;
import org.gradle.api.publish.maven.MavenArtifact;
import org.gradle.api.tasks.bundling.AbstractArchiveTask;
Expand Down Expand Up @@ -105,7 +104,7 @@ private FileNotationConverter(FileResolver fileResolver) {
public void convert(Object notation, NotationConvertResult<? super MavenArtifact> result) throws TypeConversionException {
File file = fileResolverNotationParser.parseNotation(notation);
MavenArtifact mavenArtifact = instantiator.newInstance(FileBasedMavenArtifact.class, file);
if (dependsOnTask(notation)) {
if (notation instanceof TaskDependencyContainer) {
mavenArtifact.builtBy(notation);
}
result.converted(mavenArtifact);
Expand All @@ -117,14 +116,6 @@ public void describe(DiagnosticsVisitor visitor) {
}
}

private boolean dependsOnTask(Object notation) {
if (notation instanceof ProviderInternal) {
ProviderInternal<?> provider = (ProviderInternal<?>) notation;
return provider.isContentProducedByTask() || provider.isValueProducedByTask();
}
return notation instanceof TaskDependencyContainer;
}

private class MavenArtifactMapNotationConverter extends MapNotationConverter<MavenArtifact> {
private final NotationParser<Object, MavenArtifact> sourceNotationParser;

Expand Down

0 comments on commit ab9742f

Please sign in to comment.