|
| 1 | +apply plugin: Auth0OSS |
| 2 | + |
| 3 | +class Auth0OSS implements Plugin<Project> { |
| 4 | + |
| 5 | + void apply(Project target) { |
| 6 | + target.extensions.create("auth0", Auth0Extension, target) |
| 7 | + target.configure(target) { |
| 8 | + apply plugin: 'maven-publish' |
| 9 | + |
| 10 | + target.task("sourcesJar", type: Jar, dependsOn: classes) { |
| 11 | + classifier = 'sources' |
| 12 | + from sourceSets.main.allSource |
| 13 | + } |
| 14 | + target.task("javadocJar", type: Jar, dependsOn: javadoc) { |
| 15 | + classifier = 'javadoc' |
| 16 | + from javadoc.getDestinationDir() |
| 17 | + } |
| 18 | + |
| 19 | + artifacts { |
| 20 | + archives sourcesJar, javadocJar |
| 21 | + } |
| 22 | + |
| 23 | + publishing { |
| 24 | + publications { |
| 25 | + mavenJava(MavenPublication) { |
| 26 | + from components.java |
| 27 | + artifact sourcesJar |
| 28 | + artifact javadocJar |
| 29 | + groupId project.group |
| 30 | + artifactId project.name |
| 31 | + version project.version |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + publishing.publications.all { |
| 37 | + pom.withXml { |
| 38 | + |
| 39 | + def lib = project.extensions.auth0 |
| 40 | + def root = asNode() |
| 41 | + |
| 42 | + root.appendNode('packaging', 'jar') |
| 43 | + root.appendNode('name', lib.name) |
| 44 | + root.appendNode('description', lib.description) |
| 45 | + |
| 46 | + def developersNode = root.appendNode('developers') |
| 47 | + project.extensions.auth0.developers.each { |
| 48 | + def node = developersNode.appendNode('developer') |
| 49 | + node.appendNode('id', it.id) |
| 50 | + node.appendNode('name', it.name) |
| 51 | + node.appendNode('email', it.email) |
| 52 | + } |
| 53 | + |
| 54 | + def dependenciesNode = root.appendNode('dependencies') |
| 55 | + |
| 56 | + configurations.compile.allDependencies.each { |
| 57 | + def dependencyNode = dependenciesNode.appendNode('dependency') |
| 58 | + dependencyNode.appendNode('groupId', it.group) |
| 59 | + dependencyNode.appendNode('artifactId', it.name) |
| 60 | + dependencyNode.appendNode('version', it.version) |
| 61 | + } |
| 62 | + |
| 63 | + def licenceNode = root.appendNode('licenses').appendNode('license') |
| 64 | + licenceNode.appendNode('name', 'The MIT License (MIT)') |
| 65 | + licenceNode.appendNode('url', "https://raw.githubusercontent.com/auth0/${lib.repo}/master/LICENSE") |
| 66 | + licenceNode.appendNode('distribution', 'repo') |
| 67 | + |
| 68 | + def scmNode = root.appendNode('scm') |
| 69 | + scmNode.appendNode('connection', "scm:git@github.com:auth0/${lib.repo}.git") |
| 70 | + scmNode.appendNode('developerConnection', "scm:git@github.com:auth0/${lib.repo}.git") |
| 71 | + scmNode.appendNode('url', "https://github.com/auth0/${lib.repo}") |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +class Auth0Extension { |
| 79 | + String name |
| 80 | + String repo |
| 81 | + String description |
| 82 | + List<Developer> developers = [] |
| 83 | + |
| 84 | + private Project project |
| 85 | + |
| 86 | + Auth0Extension(project) { |
| 87 | + this.project = project |
| 88 | + } |
| 89 | + |
| 90 | + void developer(Closure<Developer> developerClosure) { |
| 91 | + def developer = project.configure(new Developer(), developerClosure) |
| 92 | + developers.add(developer) |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +class Developer { |
| 97 | + String id |
| 98 | + String name |
| 99 | + String email |
| 100 | +} |
| 101 | + |
| 102 | + |
| 103 | + |
0 commit comments