Skip to content

Commit

Permalink
Generates the DbxSdkVersion value in a gradle task.
Browse files Browse the repository at this point in the history
Fixes #357
  • Loading branch information
rharter committed Aug 9, 2023
1 parent 1737bd8 commit 6cdbd7c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.dropbox.core.android.internal
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import com.dropbox.core.DbxSdkVersion
import com.dropbox.core.android.AuthActivity

Expand Down
2 changes: 1 addition & 1 deletion dropbox-sdk-java/api/dropbox-sdk-java.api
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public abstract class com/dropbox/core/DbxRequestUtil$ResponseHandler {
public abstract fun handle (Lcom/dropbox/core/http/HttpRequestor$Response;)Ljava/lang/Object;
}

public class com/dropbox/core/DbxSdkVersion {
public final class com/dropbox/core/DbxSdkVersion {
public static final field Version Ljava/lang/String;
public fun <init> ()V
}
Expand Down
21 changes: 21 additions & 0 deletions dropbox-sdk-java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,32 @@ ext {
authInfoPropertyName = 'com.dropbox.test.authInfoFile'
}

tasks.register('versionWriterTask') {
def versionName = project.property("VERSION_NAME")
it.inputs.property("versionName", versionName)

def generatedDir = project.layout.buildDirectory.dir("generated/version")
it.outputs.dir(generatedDir)

it.doLast {
def versionFile = generatedDir.get().file("com/dropbox/core/DbxSdkVersion.java").asFile
versionFile.parentFile.mkdirs()
versionFile.text = """// Generated file. Do not edit
package com.dropbox.core;
public final class DbxSdkVersion {
public static final String Version = "${versionName}";
}
"""
}
}

sourceSets {
main {
java {
// Including the Android Code this way until it is later released as a separate artifact
srcDir '../dropbox-sdk-android/src/main/java'
srcDir(versionWriterTask)
}
}
}
Expand Down
17 changes: 0 additions & 17 deletions dropbox-sdk-java/src/main/java/com/dropbox/core/DbxSdkVersion.java

This file was deleted.

0 comments on commit 6cdbd7c

Please sign in to comment.