<NME> build.gradle
<BEF> apply plugin: 'com.android.library'

android {
    compileSdkVersion 32
    resourcePrefix 'joda_'

    defaultConfig {
        minSdkVersion 14
        consumerProguardFiles 'proguard-rules.txt'
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    lintOptions {
    }
}

apply from: 'gradle-mvn-push.gradle'

repositories {
    mavenCentral()
}

configurations {
    updateTzData
}

dependencies {
    compile 'joda-time:joda-time:2.8.2:no-tzdb'
    updateTzData 'joda-time:joda-time:2.8.2'
}

task generateTzData(dependsOn: assembleDebug, type: JavaExec) {
    description = 'Generates TZ data files from the source'
    group = 'Timezone Data'

    File srcDir = new File(rootDir, 'tzdata')
    File destDir = new File(buildDir, 'intermediates/tz')

    inputs.dir srcDir
    outputs.dir destDir

    classpath configurations.updateTzData
    main = 'org.joda.time.tz.ZoneInfoCompiler'
    systemProperty 'org.joda.time.DateTimeZone.Provider', 'org.joda.time.tz.UTCProvider'
    args '-src', srcDir, '-dst', destDir, 'africa', 'antarctica', 'asia', 'australasia', 'europe',
            'northamerica', 'southamerica', 'pacificnew', 'etcetera', 'backward', 'systemv',
            'backzone'
}

//////////////////////////////////////////////////////////////////////////////
// Copies the generated TZ data into the correct place

def resFolder = 'res/raw'
def regions = ['Africa', 'America', 'America/Argentina', 'America/Kentucky', 'America/Indiana', 'America/North_Dakota', 'Antarctica', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific']

task updateTzData(dependsOn: generateTzData, type: Sync) {
    description = 'Updates the TZ data in the res/raw folder'
    group = 'Timezone Data'

    // Copy each region
    regions.each { region ->
        from("build/intermediates/tz/$region") {
            exclude '*/*'
            includeEmptyDirs false

            rename { city ->
                renameFile(region, city)
            }
        }
    }

    // Copy all root directory files (regionless)
    from("build/intermediates/tz/") {
        rename { city ->
            renameFile(null, city)
        }

        exclude '*/*'
        includeEmptyDirs false
    }

    into resFolder
}

String renameFile(String region, String city) {
    city = city.toLowerCase().replace('+', 'plus').replace('-', '_')
    if (region) {
        region = region.toLowerCase().replace('/', '_')
        'joda_time_android_tzdata_' + region + '_' + city
    } else {
        'joda_time_android_tzdata_' + city
    }
}
            classifier = "no-tzdb"
            extension = "jar"
        }
    }

    implementation libs.androidx.startup
    implementation libs.androidx.annotation

    androidTestImplementation libs.junit
    androidTestImplementation libs.androidx.test.core
    androidTestImplementation libs.androidx.test.runner
    androidTestImplementation libs.androidx.test.rules
    androidTestImplementation libs.androidx.test.ext.junit
}

tzdata {
    tzDataDir = new File(project.rootDir, 'tzdata')
}

<MSG> Merge pull request #81 from dlew/dlew/generate-raw-files

Automatically compile tzdata during builds
<DFF> @@ -14,80 +14,17 @@ android {
     }
 }
 
+apply plugin: net.danlew.android.joda.TzDataPlugin
 apply from: 'gradle-mvn-push.gradle'
 
 repositories {
     mavenCentral()
 }
 
-configurations {
-    updateTzData
-}
-
 dependencies {
     compile 'joda-time:joda-time:2.8.2:no-tzdb'
-    updateTzData 'joda-time:joda-time:2.8.2'
-}
-
-task generateTzData(dependsOn: assembleDebug, type: JavaExec) {
-    description = 'Generates TZ data files from the source'
-    group = 'Timezone Data'
-
-    File srcDir = new File(rootDir, 'tzdata')
-    File destDir = new File(buildDir, 'intermediates/tz')
-
-    inputs.dir srcDir
-    outputs.dir destDir
-
-    classpath configurations.updateTzData
-    main = 'org.joda.time.tz.ZoneInfoCompiler'
-    systemProperty 'org.joda.time.DateTimeZone.Provider', 'org.joda.time.tz.UTCProvider'
-    args '-src', srcDir, '-dst', destDir, 'africa', 'antarctica', 'asia', 'australasia', 'europe',
-            'northamerica', 'southamerica', 'pacificnew', 'etcetera', 'backward', 'systemv',
-            'backzone'
 }
 
-//////////////////////////////////////////////////////////////////////////////
-// Copies the generated TZ data into the correct place
-
-def resFolder = 'res/raw'
-def regions = ['Africa', 'America', 'America/Argentina', 'America/Kentucky', 'America/Indiana', 'America/North_Dakota', 'Antarctica', 'Asia', 'Atlantic', 'Australia', 'Etc', 'Europe', 'Indian', 'Pacific']
-
-task updateTzData(dependsOn: generateTzData, type: Sync) {
-    description = 'Updates the TZ data in the res/raw folder'
-    group = 'Timezone Data'
-
-    // Copy each region
-    regions.each { region ->
-        from("build/intermediates/tz/$region") {
-            exclude '*/*'
-            includeEmptyDirs false
-
-            rename { city ->
-                renameFile(region, city)
-            }
-        }
-    }
-
-    // Copy all root directory files (regionless)
-    from("build/intermediates/tz/") {
-        rename { city ->
-            renameFile(null, city)
-        }
-
-        exclude '*/*'
-        includeEmptyDirs false
-    }
-
-    into resFolder
-}
-
-String renameFile(String region, String city) {
-    city = city.toLowerCase().replace('+', 'plus').replace('-', '_')
-    if (region) {
-        region = region.toLowerCase().replace('/', '_')
-        'joda_time_android_tzdata_' + region + '_' + city
-    } else {
-        'joda_time_android_tzdata_' + city
-    }
+tzdata {
+    tzDataDir = new File(project.rootDir, 'tzdata')
 }

Merge pull request #81 from dlew/dlew/generate-raw-files