Question: how to exclude gradle modules (subprojects)
Given the following gradle project structure:
- project/
- build.gradle
- settings.gradle
- api/
- build.gradle
- core/
- build.gradle
- integration-tests/
- build.gradle
- utils/
- build.gradle
and the output of list-targets
$ ./fossa list-targets
[ INFO] Found project: gradle@./
[ INFO] Found target: gradle@./::api
[ INFO] Found target: gradle@./::core
[ INFO] Found target: gradle@./::integration-tests
[ INFO] Found target: gradle@./::utils
and .fossa.yml
version: 3
targets:
only:
- type: gradle
paths:
exclude:
- integration-tests
Is there a way to tell fossa to exclude the ./::integration-tests target from the analysis?
I thought a simple path exclusion would work (e.g. see above), but in the case of gradle subprojects, this doesn't seem to be the case, as they're all considered to be in the ./ root path.
@NielsDoucet Which version of fossa-cli are you using? I'm unable to reproduce on 3.2.10:
$ tree
.
├── a
│ └── build.gradle
└── b
└── build.gradle
2 directories, 2 files
$ fossa list-targets
[ INFO] Found project: gradle@a/
[ INFO] Found target: gradle@a/:
[ INFO] Found project: gradle@b/
[ INFO] Found target: gradle@b/:
If I add this to my .fossa.yml:
targets:
only:
- type: gradle
paths:
exclude:
- b
Then only the project in directory a is analyzed:
$ fossa analyze --output
[ INFO] Analyzing gradle project at /home/rolodato/source/collibra/gradle-paths/a/
[...]
Removing paths.exclude causes both directories to be analyzed:
$ rm .fossa.yml
$ fossa analyze --output
[ INFO] Analyzing gradle project at /home/rolodato/source/collibra/gradle-paths/a/
[ INFO] Analyzing gradle project at /home/rolodato/source/collibra/gradle-paths/b/
[...]
Remember that this is a multi-module gradle project. You're testing 2 separate gradle projects by running the analyze task in their parent directory.
$ tree
.
├── a
│ └── build.gradle
├── b
│ └── build.gradle
├── build.gradle
└── settings.gradle
2 directories, 4 files
This is the equivalent tree you should be testing.
And the settings.gradle file should include the following:
include("a")
include("b")
In order to make this a multi-module gradle project.
@meghfossa -- hi! I met with @NielsDoucet today and he called this out as being a major priority. It wasn't clear to me how / whether the Maven depgraph work you referenced above would address the gradle module exception requirement; when you have a moment can you please help clarify this question? Thank you!!
Hi @NielsDoucet, can you try the following?
version: 3
targets:
only:
- type: gradle
exclude:
- type: gradle
path: ./
target: ':integration-tests'
I believe this should exclude integration-tests from the analysis.
@meghfossa that does the trick indeed, thank you very much!
cc @scbrent
A few follow-up questions:
- is this documented somewhere?
- how can I exclude multiple targets? do I need the 3-line filter for each of them, or can I specify multiple targets in one of these entries?
@NielsDoucet
- Unfortunately not yet - I have an open PR now https://github.com/fossas/fossa-cli/pull/1059 that should add this into the docs
- Yes, you would need to have multiple entries. example:
version: 3
targets:
only:
- type: gradle
exclude:
- type: gradle
path: ./
target: ':app'
- type: gradle
path: ./
target: ':utilities'
Closing this issue, feel free to comment if you still need help with this. Thanks!