/var/log/messages

debugging with sixth sense

ハロワで Gradle

試しにアテてみた。以下が build.gradle です。以下なカンジの gradle.properties も必要。

storeFile=/.android/release.keystore
storePassword=hoge
keyAlias=hoge
keyPassword=hoge
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.5.+'
    }
}
apply plugin: 'android'

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    compile fileTree(dir: 'libs/armeabi', include: '*/*.so')
}

android {
    compileSdkVersion 15
    buildToolsVersion "18.1.1"

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    signingConfigs {
        debug {
            storeFile file(homeDirectory + "/.android/debug.keystore")
        }

        myConfig
    }

    if (project.hasProperty('storeFile')) {
        android.signingConfigs.myConfig.storeFile = file(homeDirectory + storeFile)
    }
    if (project.hasProperty('storePassword')) {
        android.signingConfigs.myConfig.storePassword = storePassword
    }
    if (project.hasProperty('keyAlias')) {
        android.signingConfigs.myConfig.keyAlias = keyAlias
    }
    if (project.hasProperty('keyPassword')) {
        android.signingConfigs.myConfig.keyPassword = keyPassword
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            signingConfig signingConfigs.myConfig
        }
    }
}

task copyNativeLibs(type: Copy) {
    from('libs') { include '**/*.so' }
    into new File(buildDir, 'native-libs')
}
    tasks.withType(Compile) { compileTask -> compileTask.dependsOn copyNativeLibs }

clean.dependsOn 'cleanCopyNativeLibs'

追記

build は以下なコマンドになります。

$ ANDROID_HOME=~rms/Public/adt-bundle-mac-x86_64-20130522/sdk/ ¥
JAVA_OPTS="-Dgroovy.source.encoding=UTF-8 -Dfile.encoding=UTF-8" ¥
gradle -PhomeDirectory=$HOME aR

Comments