Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/gh/lazy-tasks/buildsrc-deadlock'…
Browse files Browse the repository at this point in the history
… into release

* origin/gh/lazy-tasks/buildsrc-deadlock:
  Fix deadlock when source dependency has a buildSrc directory
  • Loading branch information
big-guy committed Oct 17, 2018
2 parents ee924b1 + 3dd7765 commit 4cf55ef
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;

public class DefaultProjectStateRegistry implements ProjectStateRegistry {
Expand All @@ -53,8 +54,9 @@ public DefaultProjectStateRegistry(WorkerLeaseService workerLeaseService) {
}

public void registerProjects(BuildState owner) {
Set<DefaultProjectDescriptor> allProjects = owner.getLoadedSettings().getProjectRegistry().getAllProjects();
synchronized (lock) {
for (DefaultProjectDescriptor descriptor : owner.getLoadedSettings().getProjectRegistry().getAllProjects()) {
for (DefaultProjectDescriptor descriptor : allProjects) {
Path identityPath = owner.getIdentityPathForProject(descriptor.path());
ProjectComponentIdentifier projectIdentifier = owner.getIdentifierForProject(descriptor.path());
ProjectStateImpl projectState = new ProjectStateImpl(owner, identityPath, descriptor.getName(), projectIdentifier);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright 2018 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.vcs.internal

import org.gradle.integtests.fixtures.AbstractIntegrationSpec
import org.gradle.vcs.fixtures.GitFileRepository
import org.junit.Rule

class BuildSrcSourceDependenciesIntegrationTest extends AbstractIntegrationSpec {
@Rule
GitFileRepository first = new GitFileRepository('first', testDirectory)

def "can build with a source dependency that has a buildSrc directory"() {
buildTestFixture.withBuildInSubDir()
vcsMapping('org.test:first', first)
singleProjectBuild("first") {
buildFile << """
apply plugin: "java"
def foo = new Foo()
"""
file("buildSrc/src/main/java/Foo.java") << """
class Foo { }
"""
}
first.commit("initial commit")

buildFile << """
configurations {
foo
}
dependencies {
foo "org.test:first:latest.integration"
}
task resolve {
doLast {
println configurations.foo.files.collect { it.name }
}
}
"""

expect:
succeeds("resolve")

and:
outputContains("[first-1.0.jar]")
}

void vcsMapping(String module, GitFileRepository repo) {
String location = repo.getWorkTree().name
settingsFile << """
sourceControl {
vcsMappings {
withModule('${module}') {
from(GitVersionControlSpec) {
url = file('${location}').toURI()
}
}
}
}
"""
}
}

0 comments on commit 4cf55ef

Please sign in to comment.