Skip to content

Commit

Permalink
fix: don't fail if matching config doesn't exist (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
ola magdziarek authored Oct 4, 2022
1 parent 90d2c57 commit 9af47fc
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
5 changes: 1 addition & 4 deletions lib/init.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ def matchesAttributeFilter(conf, confAttrSpec) {

def findMatchingConfigs(confs, confNameFilter, confAttrSpec) {
def matching = confs.findAll({ it.name =~ confNameFilter })
if (matching.isEmpty() && !confs.isEmpty()) {
throw new RuntimeException('Matching configurations ' + confNameFilter + ' were not found')
}
if (confAttrSpec == null) {
// We don't have an attribute spec to match
return matching
Expand Down Expand Up @@ -474,7 +471,7 @@ allprojects { Project currProj ->
debugLog("first level module dependencies for config `$config.name': $resConf.firstLevelModuleDependencies")
}
})
if (resolvedConfigs.isEmpty() && !resolvableConfigs.isEmpty()) {
if (!resolvableConfigs.isEmpty() && resolvedConfigs.isEmpty()) {
throw new RuntimeException('Configurations: ' + resolvableConfigs.collect { it.name } +
' for project ' + proj + ' could not be resolved.')
}
Expand Down
8 changes: 0 additions & 8 deletions test/system/failure-states.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,3 @@ test('multi-project: error on missing sub-project', async () => {
/Specified sub-project not found: "non-existent". Found these projects: subproj/,
);
});

test('error when requested configurations are not found in the project', async () => {
await expect(
inspect('.', path.join(rootNoWrapper, 'build.gradle'), {
'configuration-matching': 'nonExistentConfig',
}),
).rejects.toThrowError(/Matching configurations/);
});
22 changes: 22 additions & 0 deletions test/system/multi-module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,28 @@ test('multi-project: do not exclude subprojects with the same name as root', asy
]);
});

test('multi-project: consider matching config if it is available only in one targetted subproject', async () => {
// only greeter module has config 'downloadJar'
const options = {
'configuration-matching': 'downloadJar',
subProject: 'greeter',
};
const result = await inspect(
'.',
path.join(fixtureDir('multi-project-different-names'), 'build.gradle'),
options,
);
const pkgs = result.dependencyGraph.getDepPkgs();
const nodeIds: string[] = [];
Object.keys(pkgs).forEach((id) => {
nodeIds.push(`${pkgs[id].name}@${pkgs[id].version}`);
});

expect(
nodeIds.indexOf('org.apache.commons:[email protected]'),
).toBeGreaterThanOrEqual(0);
});

test('multi-project: use flat naming when subprojects have different names', async () => {
const result = await inspect(
'.',
Expand Down

0 comments on commit 9af47fc

Please sign in to comment.