Note: There are two branches in this repository:
kotlin
andgroovy
.
This is the Gradle project:
.
├── producer
│ └── build.gradle.kts
├── consumer
│ └── build.gradle.kts
└── settings.gradle.kts
- Register a single task, which creates a file.
- Expose ("publish" in the Gradle nomenclature) an artifact containing just that file for sharing across projects in the build.
- Declare a dependency on the producer to consume its exposed ("published") artifact.
- Register a task which uses ("resolves") that configuration's contained file.
In simple artifact sharing, we don't add any attributes to our exported configuration in the publisher.
This means that when we want to declare a dependency on this artifact from another project, we need to name the exported configuration directly. This is easy enough to do, but using artifact matching is better because it enables you to tightly couple the references to the same published configuration.
In this repository's code example, simple sharing is demonstrated by the "sharedConfiguration" configuration.
In artifact-matched sharing, we add attributes to our exported configuration so that consuming projects can automatically select the intended configuration, without having to name it. Using artifact matching enables us to make use of common code (for example, in a plugin) in order to provide a shared, coupled reference to the same artifact, we can use artifact matching.
In this repository's code example, artifact-matched sharing is demonstrated by the "anotherSharedConfiguration" configuration.