Skip to content

Commit

Permalink
Merge pull request novoda#32 from novoda/plugin/dependencies
Browse files Browse the repository at this point in the history
Introduce dependencies plugin
  • Loading branch information
ataulm authored Apr 24, 2017
2 parents 3dfbf30 + 211cd45 commit 7d4cfe3
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 12 deletions.
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
apply plugin: DependenciesPlugin

subprojects {
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.novoda:bintray-release:0.4.0'
classpath 'com.novoda:gradle-build-properties-plugin:0.2'
classpath 'org.ajoberstar:gradle-git:1.6.0'
classpath gradlePlugins.bintrayRelease
classpath gradlePlugins.buildProperties
classpath gradlePlugins.gradleGit
}
}

repositories {
jcenter()
}

project.plugins.withType(JavaBasePlugin) {
project.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
}
9 changes: 9 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repositories {
jcenter()
}

apply plugin: 'groovy'

dependencies {
compile gradleApi()
}
11 changes: 11 additions & 0 deletions buildSrc/src/main/groovy/DependenciesPlugin.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import org.gradle.api.Plugin
import org.gradle.api.Project

class DependenciesPlugin implements Plugin<Project> {

@Override
void apply(Project project) {
project.extensions.create('gradlePlugins', GradlePlugins)
project.extensions.create('libraries', Libraries, project)
}
}
5 changes: 5 additions & 0 deletions buildSrc/src/main/groovy/GradlePlugins.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class GradlePlugins {
final bintrayRelease = 'com.novoda:bintray-release:0.4.0'
final buildProperties = 'com.novoda:gradle-build-properties-plugin:0.2'
final gradleGit = 'org.ajoberstar:gradle-git:1.6.0'
}
26 changes: 26 additions & 0 deletions buildSrc/src/main/groovy/Libraries.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import org.gradle.api.Project

class Libraries {
final junit = 'junit:junit:4.12'
final truth = 'com.google.truth:truth:0.30'
final guava = 'com.google.guava:guava:19.0'
final findbugs = new Findbugs()

private final Project project

Libraries(Project project) {
this.project = project
}

def getGradleApi() {
project.dependencies.gradleApi()
}

def getGradleTestKit() {
project.dependencies.gradleTestKit()
}

private static class Findbugs {
final annotations = 'com.google.code.findbugs:jsr305:3.0.0'
}
}
15 changes: 6 additions & 9 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ apply plugin: 'groovy'
apply plugin: 'java-gradle-plugin'
apply from: rootProject.file('gradle/publish.gradle')

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

sourceSets {
test {
java {
Expand All @@ -23,13 +20,13 @@ sourceSets {
}

dependencies {
compile gradleApi()
compile libraries.gradleApi

testCompile gradleTestKit()
testCompile 'junit:junit:4.12'
testCompile 'com.google.truth:truth:0.30'
testCompile 'com.google.guava:guava:19.0'
testCompile 'com.google.code.findbugs:jsr305:3.0.0'
testCompile libraries.gradleTestKit
testCompile libraries.junit
testCompile libraries.truth
testCompile libraries.guava
testCompile libraries.findbugs.annotations

testRuntime files(pluginUnderTestMetadata)
}

0 comments on commit 7d4cfe3

Please sign in to comment.