Skip to content

Instantly share code, notes, and snippets.

@bamboo
Last active November 24, 2015 10:18
Show Gist options
  • Save bamboo/99cee19826c148fd480b to your computer and use it in GitHub Desktop.
Save bamboo/99cee19826c148fd480b to your computer and use it in GitHub Desktop.
External Components as First Class Model Elements
model {
components {
// External components are modeled just like internal ones.
mavenLibrary 'collections' {
org 'com.acme'
version '1.0'
}
// And thus can be required just like any other component
jvmLibrary 'consumer' {
requires 'collections'
}
// By treating external components as first class we open the door
// for further extension, for example, we could decide to build
// the same external component directly from a specific github commit
// with a hypothetical `github-components` plugin that exposes a
// `githubLibrary` component constructor.
githubLibrary 'collections' {
repository 'acme/collections'
commit 'abbacada'
}
// Later on we might even decide to implement 'collections' locally.
jvmLibrary 'collections' {
}
// And consuming libraries would remain oblivious to these changes on how
// the external component is actually produced.
jvmLibrary 'foo' {
requires 'collections'
}
jvmLibrary 'bar' {
requires 'collections'
}
// org:name:version acts a shorthand version for
// defining and requiring an external component in
// a single step
jvmLibrary 'baz' {
// This will implicitly create a external component and require it
requires 'com.acme:collections:2.0'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment