Skip to content

Commit b5d0f56

Browse files
authored
Add contributing instructions (#227)
1 parent 2cfd77c commit b5d0f56

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

README.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,55 @@ 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-
### Notes on the Plugins history
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+
36+
### (1) Use patch DSL to add rule in your build
37+
38+
You can use the [patch DSL](https://gradlex.org/jvm-dependency-conflict-resolution/#patch-dsl-block) to add the missing rule without modifying the plugin. Do this first and verify that it behaves as expected:
39+
40+
```kotlin
41+
// Assuming 'org.example:name' and 'org.example.new:new-name' are in conflict
42+
jvmDependencyConflicts {
43+
patch {
44+
module("org.example:name") { addCapability("org.mydomain:name") }
45+
module("org.example.new:new-name") { addCapability("org.mydomain:name") }
46+
conflictResolution {
47+
selectHighestVersion("com.mydomain:name")
48+
}
49+
}
50+
```
51+
52+
### (2) Contribute rule
53+
54+
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.
55+
This is done as follows:
56+
57+
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.
58+
You can use the [ASM](https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/src/main/java/org/gradlex/jvm/dependency/conflict/detection/rules/CapabilityDefinition.java#L69-L72) entry as orientation.
59+
2. Run the `JarOverlapTest`.
60+
The test will tell you that you need to add dependencies 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+
78+
## Notes on the Plugins history
3179
3280
These plugins join, unify and extend functionalities that were previously part of the following discontinued plugins:
3381

0 commit comments

Comments
 (0)