Skip to content

Commit 7b8501b

Browse files
committed
Add contributing instructions
1 parent 2cfd77c commit 7b8501b

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,54 @@ See the [documentation](https://gradlex.org/jvm-dependency-conflict-resolution/)
2727
Note: There are rules in this plugin (in particular for _Guava_) which work _better_ with Gradle `7+`.
2828
This is because Gradle 7 added support for the `org.gradle.jvm.environment` attribute that allows Gradle to better distinguish between _standard-jvm_ and _android_ projects.
2929

30+
## Contributing new capability rules
31+
32+
This plugin collects information for libraries available on Maven Central to allow capability conflict detection.
33+
If you discover that information is missing, we appreciate a contribution to the plugin.
34+
An indication that such information is missing, is that you have duplicated classes on your classpath although this plugin is active.
35+
Follow these steps
36+
37+
### (1) Use patch DSL to add rule in your build
38+
39+
You can use the patch DSL to add the missing rule without modifying the plugin. Do this first and verify that it behaves as expected:
40+
41+
```
42+
// Assuming 'org.example:name' and 'org.example.new:new-name' are in conflict
43+
jvmDependencyConflicts {
44+
patch {
45+
module("org.example:name") { addCapability("org.mydomain:name") }
46+
module("org.example.new:new-name") { addCapability("org.mydomain:name") }
47+
conflictResolution {
48+
selectHighestVersion("com.mydomain:name")
49+
}
50+
}
51+
```
52+
53+
### (2) Contribute rule
54+
55+
Once you confirmed that the rule is working as expected, you can open a PR in this repository to contribute your findings back to the plugin.
56+
This is done as follows:
57+
58+
1. Add a new entry to the [CapabilityDefinition](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/src/main/java/org/gradlex/jvm/dependency/conflict/detection/rules/CapabilityDefinition.java) enum.
59+
2. Run the `JarOverlapTest`.
60+
The test will tell you that you need to add entries to `samples/sample-all/build.gradle.kts` and `samples/sample-all-deactivated/build.gradle.kts`.
61+
Lookup the latest versions of the dependencies and add them to the files.
62+
This is so that the plugin's test suite can automatically verify that the new entry is valid in the sense that the Jars overlap.
63+
Make sue `JarOverlapTest` passes after you made the changes.
64+
3. Run the `SamplesTest`.
65+
It will tell you that `samples/sample-all/build.out` and `samples/sample-all-deactivated/build.out` do not have the expected content.
66+
Update these files accordingly (you may copy the new expected output from the failed test's output).
67+
This is the output of Gradle's `dependencies` task. Check that the changes are what you would expect.
68+
Make sue `SamplesTest` passes after you made the changes.
69+
70+
Create a PR with the changes to the files:
71+
- [CapabilityDefinition.java](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/src/main/java/org/gradlex/jvm/dependency/conflict/detection/rules/CapabilityDefinition.java)
72+
- [samples/sample-all/build.gradle.kts](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/samples/sample-all/build.gradle.kts)
73+
- [samples/sample-all/build.out](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/samples/sample-all/build.out)
74+
- [samples/sample-all-deactivated/build.gradle.kts](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/samples/sample-all-deactivated/build.gradle.kts)
75+
- [samples/sample-all-deactivated/build.out](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/samples/sample-all-deactivated/build.out)
76+
77+
3078
### Notes on the Plugins history
3179

3280
These plugins join, unify and extend functionalities that were previously part of the following discontinued plugins:

0 commit comments

Comments
 (0)