Skip to content
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

Remove deprecated internal constructor #3591

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@
import org.gradle.api.artifacts.PublishArtifact;
import org.gradle.api.attributes.AttributeContainer;
import org.gradle.api.attributes.Usage;
import org.gradle.api.internal.attributes.DefaultImmutableAttributesFactory;
import org.gradle.api.internal.attributes.ImmutableAttributes;
import org.gradle.api.internal.attributes.ImmutableAttributesFactory;
import org.gradle.api.internal.component.SoftwareComponentInternal;
import org.gradle.api.internal.component.UsageContext;
import org.gradle.api.internal.model.DefaultObjectFactory;
import org.gradle.api.internal.model.NamedObjectInstantiator;
import org.gradle.api.model.ObjectFactory;
import org.gradle.internal.reflect.DirectInstantiator;

import javax.inject.Inject;
import java.util.LinkedHashSet;
Expand All @@ -45,10 +41,6 @@
* A SoftwareComponent representing a library that runs on a java virtual machine.
*/
public class JavaLibrary implements SoftwareComponentInternal {

// This must ONLY be used in the deprecated constructor, for backwards compatibility
private final static ObjectFactory DEPRECATED_OBJECT_FACTORY = new DefaultObjectFactory(DirectInstantiator.INSTANCE, NamedObjectInstantiator.INSTANCE);

private final Set<PublishArtifact> artifacts = new LinkedHashSet<PublishArtifact>();
private final UsageContext runtimeUsage;
private final UsageContext compileUsage;
Expand All @@ -66,20 +58,6 @@ public JavaLibrary(ObjectFactory objectFactory, ConfigurationContainer configura
this.compileUsage = new CompileUsageContext(Usage.JAVA_API);
}

/**
* This constructor should not be used, and is maintained only for backwards
* compatibility with the widely used Shadow plugin.
*/
@Deprecated
public JavaLibrary(PublishArtifact jarArtifact, DependencySet runtimeDependencies) {
this.artifacts.add(jarArtifact);
this.objectFactory = DEPRECATED_OBJECT_FACTORY;
this.attributesFactory = new DefaultImmutableAttributesFactory(null);
this.runtimeUsage = new BackwardsCompatibilityUsageContext(Usage.JAVA_RUNTIME, runtimeDependencies);
this.compileUsage = new BackwardsCompatibilityUsageContext(Usage.JAVA_API, runtimeDependencies);
this.configurations = null;
}

@VisibleForTesting
Set<PublishArtifact> getArtifacts() {
return artifacts;
Expand Down Expand Up @@ -156,23 +134,4 @@ public Set<ModuleDependency> getDependencies() {
return dependencies.withType(ModuleDependency.class);
}
}

private class BackwardsCompatibilityUsageContext extends AbstractUsageContext {
private final DependencySet runtimeDependencies;

private BackwardsCompatibilityUsageContext(String usageName, DependencySet runtimeDependencies) {
super(usageName);
this.runtimeDependencies = runtimeDependencies;
}

@Override
public String getName() {
return getUsage().getName();
}

@Override
public Set<ModuleDependency> getDependencies() {
return runtimeDependencies.withType(ModuleDependency.class);
}
}
}