Skip to content

Commit

Permalink
Converted Stone Gradle Code into a Kotlin Gradle Plugin (#451)
Browse files Browse the repository at this point in the history
* Plugin Structure

* Added Stone Plugin

* Working Gradle Plugin

* Swap the default and the custom configs.

* Config Updated

* No longer need stone.gradle

* Added new plugin to examples.

* Add output directory as source afterEvaluate.

* Moved plugin to different package.

* Removed unused code.

* Code cleanup pass.
  • Loading branch information
handstandsam committed Sep 26, 2022
1 parent 6ea4ae7 commit 469aefb
Show file tree
Hide file tree
Showing 13 changed files with 451 additions and 298 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ buildscript {
classpath files('gradle/dropbox-pem-converter-plugin')
classpath(dropboxJavaSdkLibs.android.gradle.plugin)
classpath(dropboxJavaSdkLibs.kotlin.gradle.plugin)
classpath("com.dropbox.gradle.plugins:stone-java-gradle-plugin")
}
}

Expand Down
69 changes: 65 additions & 4 deletions dropbox-sdk-java/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import com.dropbox.stone.java.model.ClientSpec
import com.dropbox.stone.java.model.StoneConfig

plugins {
id 'java-library'
id "com.github.blindpirate.osgi"
Expand All @@ -7,6 +10,9 @@ plugins {
id "com.dropbox.dependency-guard"
}

dependencyGuard {
configuration("runtimeClasspath")
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down Expand Up @@ -239,9 +245,64 @@ dependencyUpdates.resolutionStrategy = {
}
}

apply from: 'stone.gradle'
apply plugin: "com.dropbox.stone.java"

generateStone {
String unusedClassesToGenerate = 'AuthError, PathRoot, PathRootError, AccessError, RateLimitError'
String packageName = 'com.dropbox.core.v2'
String globalRouteFilter = 'alpha_group=null and beta_group=null'
config[
new StoneConfig(
packageName: packageName,
globalRouteFilter: globalRouteFilter,
client: new ClientSpec(
name: 'DbxClientV2Base',
javadoc: 'Base class for user auth clients.',
requestsClassnamePrefix: "DbxUser",
routeFilter: 'auth="user" or auth="noauth" or auth="app, user"',
unusedClassesToGenerate: unusedClassesToGenerate,
),
),
new StoneConfig(
packageName: packageName,
globalRouteFilter: globalRouteFilter,
client: new ClientSpec(
name: 'DbxTeamClientV2Base',
javadoc: 'Base class for team auth clients.',
requestsClassnamePrefix: 'DbxTeam',
routeFilter: 'auth="team"',
),
),
new StoneConfig(
packageName: packageName,
globalRouteFilter: globalRouteFilter,
client: new ClientSpec(
name: 'DbxAppClientV2Base',
javadoc: 'Base class for app auth clients.',
requestsClassnamePrefix: "DbxApp",
routeFilter: 'auth="app" or auth="app, user"',
)
),

]
outputDir "${project.projectDir}/generated_stone_source/main"
}

dependencyGuard {
configuration("runtimeClasspath")
configuration("compileClasspath")
generateTestStone {
String packageName = 'com.dropbox.core.stone'
config[
new StoneConfig(
packageName: packageName,
dataTypesOnly: true,
),
new StoneConfig(
packageName: packageName,
client: new ClientSpec(
name: 'DbxClientV2Base',
javadoc: 'TestClass.',
requestsClassnamePrefix: "DbxTest",
)
),
]
outputDir "${project.projectDir}/generated_stone_source/test"
}
292 changes: 0 additions & 292 deletions dropbox-sdk-java/stone.gradle

This file was deleted.

1 change: 1 addition & 0 deletions examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ buildscript {
classpath "com.android.tools.build:gradle:7.2.1"
classpath files('../gradle/dropbox-pem-converter-plugin')
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21"
classpath("com.dropbox.gradle.plugins:stone-java-gradle-plugin")
}
}
plugins {
Expand Down
Loading

0 comments on commit 469aefb

Please sign in to comment.