android - Gradle - build sass per productflavor (multi folder) -
we created android app webview shows local website assets folder.
the project has different product flavors generate diffent apps different styles , content same codebas (native java , html / js).
for each flavor want define diffent sass file colors , tweaks specific flavour.
i know need create task in gradle builds css files have no idea start:
- how url of assets folder of specific flavour?
- can use special gradle plugin building sass or have create task executes "sass" command?
- when use gradle plugin compass, how configure right folders each flavour? plugin settings in top level , not in android plugin level.
i finaly have solution!
add build.gradle in main folder (not of app):
buildscript { repositories { jcenter() mavencentral() maven { url 'http://dl.bintray.com/robfletcher/gradle-plugins' } } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.github.robfletcher:compass-gradle-plugin:2.0.6' // note: not place application dependencies here; belong // in individual module build.gradle files } } allprojects { repositories { jcenter() } }
add build.gradle of app module:
apply plugin: 'com.android.application' apply plugin: 'com.github.robfletcher.compass' android { [..] android.applicationvariants.all { variant -> (output in variant.outputs) { def assetsdir = output.packageapplication.assets; tasks["merge${variant.name.capitalize()}assets"].dolast() { println "assets folder: " + assetsdir def _ccsdir = file("$assetsdir/css") def _sassdir = file("$assetsdir/sass") def _imagesdir = file("$assetsdir/images") def _javascriptsdir = file("$assetsdir/js") def _fontsdir = file("$assetsdir/fonts") project.compass { cssdir = _ccsdir sassdir = _sassdir imagesdir = _imagesdir javascriptsdir = _javascriptsdir fontsdir = _fontsdir } //compilesass project.compasscompile.execute() } } } }
i never thought work out works!
Comments
Post a Comment