How to configure build.gradle files of an existing project with actionbarsherlock lib? - actionbarsherlock

I have an existing project MyProject in eclipse that use the library actionbarsherlock (version 4.3.1). The project compiles and runs in android studio, but I don't get build variants. Please help!
Here is setting.gradle and build.gradle of my root folder (project_workspace):
// setting.gradle:
include ':MyProject'
include ':actionbarsherlock'
build.grade:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:gradle:0.4'
}
}
build.gradle of myProject:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':C::Users:<myname>:project_workspace:actionbarsherlock')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
build.gradle of actionbarsherlock:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 14
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
I also read a lot of question and answers here, and I looked at the gradle samples, but I don't get it.
Please help me, I never worked with maven or ant before!
If you need more information -> tell me.

I have working project with libs like this:
Root folder:
settings.gradle:
include ':JazzyListView', ':ABS', ':Volley',':WallCP'
build.gradle: empty
ABS folder:
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android-library'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
}
}
Main project's folder:
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':JazzyListView')
compile project(':ABS')
compile project(':Volley')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
versionCode 5
versionName "3.0"
minSdkVersion 8
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java']
res.srcDirs = ['src/main/res']
}
}
}

Related

Grunt not compiling sass

I am working with an old project which uses grunt as a build tool, I had to install newer version of node-sass since to be able to rebuild node-sass. Now when I am trying to make changes in sass files, and run grunt I don't that anything has compiled. This is my Gruntfile.js:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
outputStyle: 'compressed',
sourceComments: 'none'
},
files: {
'css/app.css': 'scss/app.scss'
}
},
dev: {
options: {
outputStyle: 'expanded',
sourceComments: 'map',
sourceMap: 'app.css.map'
},
files: {
'css/app.css': 'scss/app.scss'
}
}
},
watch: {
grunt: { files: ['Gruntfile.js'] },
sass: {
files: 'assets/scss/**/*.scss',
tasks: ['sass:dev']
},
css: {
files: ['assets/css/*.css'],
tasks: [],
options: {
livereload: true
}
}
}
});
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('build', ['sass:dist']);
grunt.registerTask('default', ['sass:dev', 'watch']);
}
How can I fix this?
Looks like your path is wrong in your SASS task.
Replace:
'scss/app.scss'
with
'assets/scss/app.scss'

grunt-contrib-sass doesn't work in Windows

I am trying to compile scss file to css using Grunt, but I fail for unknown reason.
Here is my Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
bower: {
install: {
options: {
targetDir: 'dependencies',
cleanup: true,
layout: 'byComponent'
}
}
},
sass: {
foundation: {
files: {
'a.css': 'a.scss'
}
}
}
});
grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.registerTask('dependencies', ['bower:install']);
grunt.registerTask('assets', ['sass:foundation']);
};
I am getting the following error:
> grunt assets
Running "sass:foundation" (sass) task
Warning: spawn C:\Windows\system32\cmd.exe;C\MySQL\bin ENOENT Use --force to continue
Aborted due to warnings.
What am I doing wrong?
i resolved the issue, installing "grunt-contrib-sass": "^0.8.1" (that's a old version, but it's works for me)
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-sass": "^0.8.1"
}

grunt-newer won't work properly with Watchify

I use Grunt for Node with a bunch of packages. For example jsHint, jsDoc, Browserify, Uglify ...
I run the Gruntfile with Watchify and Newer for automation. So far, so good.
The Gruntfile, which works totaly fine:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: ['my/js/files/*.js']
},
jsdoc : {
dist : {
src: ['my/js/files/*.js'],
options: {
destination: 'doc'
}
}
},
browserify: {
'public/js/files/script.js': ['my/js/files/*.js']
},
uglify: {
my_target: {
files: {
'public/js/files/script.js': ['public/js/files/script.js']
}
}
},
htmlmin: {
dist: {
files: {
'public/html/index.html': ['public/html/index.html']
}
}
},
cssmin: {
combine: {
files: {
'public/css/css.min.css': ['my/css/files/*.css']
}
}
},
watch: {
javascript: {
files: ['my/js/files/*.js'],
tasks: ['newer:jshint:all', 'jsdoc', 'browserify', 'uglify']
},
html: {
files: ['public/html/index.html'],
tasks: ['htmlmin']
},
css: {
files: ['public/css/*.css'],
tasks: ['cssmin']
}
}
});
// load plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-newer');
};
It works as far as I only use Newer for jsHint. But if I try the same with jsDoc or Uglify I get Error-Messages.
Example:
I try this ...
tasks: ['newer:jshint:all', 'newer:jsdoc:all', 'browserify', 'uglify']
instead of ...
tasks: ['newer:jshint:all', 'jsdoc', 'browserify', 'uglify']
I get Error-Messages:
Running "newer:jsdoc:all" (newer) task
Warning: Cannot read property 'files' of undefined Use --force to continue.
Aborted due to warnings.
Why does it work for jsHint but not for the rest? Has anybody an idea? Would much appreciate some Hints!
Kind regards
the target of your jshint task is all, so newer:jshint:all is correct.
your jsdoc target is dist, so you have to use this target: newer:jsdoc:dist
for you it is even easier, you only have one target per task (only your watch task has multiple targets) so you could only do it like this:
['newer:jshint', 'newer:jsdoc', 'browserify', 'uglify']

grunt-contrib-less creates the app.css file during launch but not during live reload

Basically, at the beginning all is ok but after modifications, CSS are not updated.
First, my package details:
"node" : "0.10.21"
[...]
"grunt": "~0.4.1",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-jshint": "~0.7.1",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-less": "~0.8.1"
Next, my gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ''
},
dist: {
src: [ 'src/js/libs/jquery-2.0.3.min.js',
'src/js/libs/**/*.js',
'src/js/app/**/*.js'],
dest: 'public/js/combo.js'
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'public/js/combo.min.js': ['public/js/combo.js']
}
}
},
less: {
compile: {
options: {
compress:true
},
files: {
'public/css/application.css': ['src/css/application.less']
}
}
},
jshint: {
files: ['gruntfile.js', 'src/js/**/*.js','src/css/**/*.less','public/index.html'],
options: {
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['default']
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['concat','uglify','less','watch']);
};
Explanations
At first, all works perfectly, all the files are created:
Running "concat:dist" (concat) task
File "public/js/combo.js" created.
Running "uglify:dist" (uglify) task
File "public/js/combo.min.js" created.
Running "less:compile" (less) task
App runnning on http://localhost:3000
File public/css/application.css created.
Running "watch" task
Waiting...
But, if I make a modification in my *.less files:
OK
>> File "src\css\application.less" changed.
Running "concat:dist" (concat) task
Completed in 2.039s at Tue Nov 12 2013 11:44:53 GMT-0500 (Eastern Standard Time) - Waiting...
So, modifying is detected by watch but my CSS file is not updated and I just can't figure why. I tried several contrib-less implementations and it keeps the same way. I guess I'm doing something wrong but what ?
PS: concat and uglify are working very well.

Using require-js and grunt.js - error missing either a "name", "include" or"modules" option

My Gruntfile.js file:
module.exports = function (grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
requirejs : {
compile: {
options: {
baseUrl: "public_html/js",
mainConfigFile: "public_html/js/config.js",
out: "public_html/app.min.js"
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('default', ['requirejs']);
};
My config.js file:
'use strict';
require.config({
deps: ['main'],
paths: {
jquery: 'vendor/jquery',
jquery_tokeninput: 'vendor/jquery.tokeninput',
underscore: 'vendor/underscore',
backbone: 'vendor/backbone'
},
shim: {
jquery: [],
jquery_tokeninput: {
deps: ['jquery']
},
backbone: {
deps: ['vendor/underscore', 'vendor/jquery', 'vendor/jquery.tokeninput'],
exports: 'Backbone'
},
underscore: {
exports: '_'
}
}
});
require(['views/app'], function(AppView) {
new AppView;
});
When I run grunt requirejs it errors with:
Running "requirejs:compile" (requirejs) task
[Error: Error: Missing either a "name", "include" or "modules" option at function.build.createConfig (D:\project\node_modules\grunt-contrib-requirejs\node_modules\requirejs\bin\r.js:24829:19)]
First time using gruntjs and requirejs so not sure why I'm getting the error.
Updated the grunt.js file to use name:
module.exports = function (grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON('package.json'),
requirejs : {
compile: {
options: {
name: "views/app",
baseUrl: "public_html/js",
mainConfigFile: "public_html/js/config.js",
out: "public_html/app.min.js"
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('default', ['requirejs']);
};
and removed the following from the config.js:
require(['views/app'], function(AppView) {
new AppView;
});

Resources