Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release'
Browse files Browse the repository at this point in the history
* origin/release:
  Bump to 4.10.2 nightly
  Recommend people update to 4.10.2, not base 4.10
  Reset public API and baseline for comparison
  Bump to 4.10.2
  Fix #6750
  Fix #6735
  • Loading branch information
big-guy committed Sep 17, 2018
2 parents 37e3654 + b4d8d5d commit df55bee
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Expand Up @@ -16,7 +16,6 @@
package org.gradle.scala

import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import spock.lang.Ignore
import spock.lang.Issue

class ScalaPluginIntegrationTest extends AbstractIntegrationSpec {
Expand Down Expand Up @@ -72,7 +71,6 @@ task someTask
succeeds(":a:classes", "--parallel")
}

@Ignore
@Issue("https://github.com/gradle/gradle/issues/6735")
def "can depend on the source set of another Java project"() {
settingsFile << """
Expand Down Expand Up @@ -107,7 +105,6 @@ task someTask
succeeds(":scala:testClasses")
}

@Ignore
@Issue("https://github.com/gradle/gradle/issues/6750")
def "can depend on Scala project from other project"() {
settingsFile << """
Expand Down Expand Up @@ -136,6 +133,7 @@ task someTask
}
project(":scala") {
apply plugin: 'scala'
dependencies {
compile("org.scala-lang:scala-library:2.12.6")
}
Expand Down
Expand Up @@ -16,14 +16,21 @@
package org.gradle.api.plugins.scala;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableSet;
import org.codehaus.groovy.runtime.InvokerHelper;
import org.gradle.api.Action;
import org.gradle.api.ActionConfiguration;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.artifacts.ArtifactView;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.DependencySet;
import org.gradle.api.artifacts.component.ComponentIdentifier;
import org.gradle.api.artifacts.component.ProjectComponentIdentifier;
import org.gradle.api.attributes.AttributeDisambiguationRule;
import org.gradle.api.attributes.AttributeMatchingStrategy;
import org.gradle.api.attributes.MultipleCandidatesDetails;
import org.gradle.api.attributes.Usage;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileTreeElement;
Expand Down Expand Up @@ -78,7 +85,7 @@ public void apply(final Project project) {
configureScaladoc(project, scalaRuntime);
}

private void configureConfigurations(final Project project, Usage incrementalAnalysisUsage) {
private void configureConfigurations(final Project project, final Usage incrementalAnalysisUsage) {
project.getConfigurations().create(ZINC_CONFIGURATION_NAME).setVisible(false).setDescription("The Zinc incremental compiler to be used for this Scala project.")
.defaultDependencies(new Action<DependencySet>() {
@Override
Expand All @@ -93,6 +100,16 @@ public void execute(DependencySet dependencies) {
incrementalAnalysisElements.setCanBeResolved(false);
incrementalAnalysisElements.setCanBeConsumed(true);
incrementalAnalysisElements.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, incrementalAnalysisUsage);

AttributeMatchingStrategy<Usage> matchingStrategy = project.getDependencies().getAttributesSchema().attribute(Usage.USAGE_ATTRIBUTE);
matchingStrategy.getDisambiguationRules().add(UsageDisambiguationRules.class, new Action<ActionConfiguration>() {
@Override
public void execute(ActionConfiguration actionConfiguration) {
actionConfiguration.params(incrementalAnalysisUsage);
actionConfiguration.params(objectFactory.named(Usage.class, Usage.JAVA_API));
actionConfiguration.params(objectFactory.named(Usage.class, Usage.JAVA_RUNTIME_JARS));
}
});
}

private static void configureSourceSetDefaults(final Project project, final Usage incrementalAnalysisUsage, final ObjectFactory objectFactory) {
Expand Down Expand Up @@ -164,6 +181,12 @@ public File call() throws Exception {
@Override
public void execute(ArtifactView.ViewConfiguration viewConfiguration) {
viewConfiguration.lenient(true);
viewConfiguration.componentFilter(new Spec<ComponentIdentifier>() {
@Override
public boolean isSatisfiedBy(ComponentIdentifier element) {
return element instanceof ProjectComponentIdentifier;
}
});
}
}).getFiles());
}
Expand Down Expand Up @@ -223,4 +246,24 @@ public FileCollection call() throws Exception {
}
});
}

static class UsageDisambiguationRules implements AttributeDisambiguationRule<Usage> {
private final ImmutableSet<Usage> expectedUsages;
private final Usage javaRuntimeJars;

@Inject
UsageDisambiguationRules(Usage incrementalAnalysis, Usage javaApi, Usage javaRuntimeJars) {
this.javaRuntimeJars = javaRuntimeJars;
this.expectedUsages = ImmutableSet.of(incrementalAnalysis, javaApi, javaRuntimeJars);
}

@Override
public void execute(MultipleCandidatesDetails<Usage> details) {
if (details.getConsumerValue() == null) {
if (details.getCandidateValues().equals(expectedUsages)) {
details.closestMatch(javaRuntimeJars);
}
}
}
}
}

0 comments on commit df55bee

Please sign in to comment.