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

Fix: subprojects filtering #278

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions lib/init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ allprojects { Project currProj ->
def shouldScanProject = {
onlyProj == null ||
(onlyProj == '.' && it.name == defaultProjectName) ||
it.name == onlyProj
it.name == onlyProj ||
formatPath(it.path) == onlyProj
}
def projectsDict = [:]

Expand Down Expand Up @@ -433,7 +434,8 @@ allprojects { Project currProj ->
def shouldScanProject = {
onlyProj == null ||
(onlyProj == '.' && it.name == defaultProjectName) ||
it.name == onlyProj
it.name == onlyProj ||
formatPath(it.path) == onlyProj
}
def projectsDict = [:]

Expand Down
68 changes: 35 additions & 33 deletions test/fixtures-with-wrappers/with-lock-file/dep-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
}
},
{
"id": "com.google.guava:guava@32.1.3-jre",
"id": "com.google.guava:guava@33.0.0-jre",
"info": {
"name": "com.google.guava:guava",
"version": "32.1.3-jre"
"version": "33.0.0-jre"
}
},
{
Expand All @@ -33,10 +33,10 @@
}
},
{
"id": "com.google.guava:[email protected].1",
"id": "com.google.guava:[email protected].2",
"info": {
"name": "com.google.guava:failureaccess",
"version": "1.0.1"
"version": "1.0.2"
}
},
{
Expand All @@ -54,17 +54,17 @@
}
},
{
"id": "org.checkerframework:checker-qual@3.37.0",
"id": "org.checkerframework:checker-qual@3.41.0",
"info": {
"name": "org.checkerframework:checker-qual",
"version": "3.37.0"
"version": "3.41.0"
}
},
{
"id": "com.google.errorprone:error_prone_annotations@2.21.1",
"id": "com.google.errorprone:error_prone_annotations@2.23.0",
"info": {
"name": "com.google.errorprone:error_prone_annotations",
"version": "2.21.1"
"version": "2.23.0"
}
},
{
Expand All @@ -74,6 +74,13 @@
"version": "2.11.0"
}
},
{
"id": "com.google.guava:[email protected]",
"info": {
"name": "com.google.guava:failureaccess",
"version": "1.0.1"
}
},
{
"id": "org.checkerframework:[email protected]",
"info": {
Expand All @@ -100,7 +107,7 @@
"nodeId": "org.codehaus.groovy:[email protected]"
},
{
"nodeId": "com.google.guava:guava@32.1.3-jre"
"nodeId": "com.google.guava:guava@33.0.0-jre"
},
{
"nodeId": "com.google.guava:[email protected]"
Expand All @@ -113,11 +120,11 @@
"deps": []
},
{
"nodeId": "com.google.guava:guava@32.1.3-jre",
"pkgId": "com.google.guava:guava@32.1.3-jre",
"nodeId": "com.google.guava:guava@33.0.0-jre",
"pkgId": "com.google.guava:guava@33.0.0-jre",
"deps": [
{
"nodeId": "com.google.guava:[email protected].1"
"nodeId": "com.google.guava:[email protected].2"
},
{
"nodeId": "com.google.guava:[email protected]"
Expand All @@ -126,20 +133,17 @@
"nodeId": "com.google.code.findbugs:[email protected]"
},
{
"nodeId": "org.checkerframework:checker-qual@3.37.0"
"nodeId": "org.checkerframework:checker-qual@3.41.0"
},
{
"nodeId": "com.google.errorprone:error_prone_annotations@2.21.1"
"nodeId": "com.google.errorprone:error_prone_annotations@2.23.0"
}
]
},
{
"nodeId": "com.google.guava:[email protected]",
"pkgId": "com.google.guava:[email protected]",
"deps": [
{
"nodeId": "com.google.guava:[email protected]:pruned"
},
{
"nodeId": "com.google.guava:[email protected]:pruned"
},
Expand All @@ -149,6 +153,9 @@
{
"nodeId": "com.google.errorprone:[email protected]"
},
{
"nodeId": "com.google.guava:[email protected]"
},
{
"nodeId": "org.checkerframework:[email protected]"
},
Expand All @@ -158,8 +165,8 @@
]
},
{
"nodeId": "com.google.guava:[email protected].1",
"pkgId": "com.google.guava:[email protected].1",
"nodeId": "com.google.guava:[email protected].2",
"pkgId": "com.google.guava:[email protected].2",
"deps": []
},
{
Expand All @@ -173,25 +180,15 @@
"deps": []
},
{
"nodeId": "org.checkerframework:checker-qual@3.37.0",
"pkgId": "org.checkerframework:checker-qual@3.37.0",
"nodeId": "org.checkerframework:checker-qual@3.41.0",
"pkgId": "org.checkerframework:checker-qual@3.41.0",
"deps": []
},
{
"nodeId": "com.google.errorprone:error_prone_annotations@2.21.1",
"pkgId": "com.google.errorprone:error_prone_annotations@2.21.1",
"nodeId": "com.google.errorprone:error_prone_annotations@2.23.0",
"pkgId": "com.google.errorprone:error_prone_annotations@2.23.0",
"deps": []
},
{
"nodeId": "com.google.guava:[email protected]:pruned",
"pkgId": "com.google.guava:[email protected]",
"deps": [],
"info": {
"labels": {
"pruned": "true"
}
}
},
{
"nodeId": "com.google.guava:[email protected]:pruned",
"pkgId": "com.google.guava:[email protected]",
Expand All @@ -217,6 +214,11 @@
"pkgId": "com.google.errorprone:[email protected]",
"deps": []
},
{
"nodeId": "com.google.guava:[email protected]",
"pkgId": "com.google.guava:[email protected]",
"deps": []
},
{
"nodeId": "org.checkerframework:[email protected]",
"pkgId": "org.checkerframework:[email protected]",
Expand Down
20 changes: 20 additions & 0 deletions test/system/multi-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,26 @@ test('multi-project: correct deps for subproject with the same name, one depende
expect(nodeIds.indexOf('joda-time:[email protected]')).toBe(-1);
});

test('multi-project: right subproject to scan, using --sub-project', async () => {
const result = await inspect(
'.',
path.join(fixtureDir('subprojects-same-name'), 'build.gradle'),
{ subProject: 'greeter/subproj' },
);

expect(result.dependencyGraph.rootPkg.name).toBe(
'subprojects-same-name/greeter/subproj',
);
expect(result.meta!.gradleProjectName).toBe(
'subprojects-same-name/greeter/subproj',
);
expect(result.plugin.meta!.allSubProjectNames).toEqual([
'greeter',
'subproj',
'greeter/subproj',
]);
});

test('multi-project: correct deps for subproject with the same name, one dependent on another, using --sub-project', async () => {
const result = await inspect(
'.',
Expand Down