Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sten Roger Sandvik
committed
May 19, 2013
0 parents
commit 8e1d610
Showing
7 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
build/ | ||
.gradle/ | ||
*.iws | ||
*.ids | ||
*.iml | ||
*.ipr | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
Running Grunt from Gradle | ||
------------------------- | ||
|
||
* Install packages | ||
** Check if node is installed | ||
** Check if npm is installed | ||
** Check if grunt-cli is installed | ||
*** Install if not found | ||
** Install npm packages | ||
|
||
* Detect nodejs and npm installed (and right versions) | ||
* Create package.json for simple grunt project | ||
* Install npm packages | ||
* Gradle task for running grunt task | ||
|
||
Settings | ||
-------- | ||
|
||
* Path to node | ||
* Path to grunt | ||
* Path to npm | ||
* Use local grunt? | ||
|
||
|
||
http://blog.crisp.se/2013/04/30/yassalsundman/test-driving-javascript-grunt-with-gradle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apply plugin: 'idea' | ||
apply plugin: 'groovy' | ||
apply plugin: 'maven' | ||
|
||
version = '0.1-SNAPSHOT' | ||
group = 'com.moowork.gradle' | ||
|
||
dependencies { | ||
compile gradleApi() | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/groovy/com/moowork/gradle/grunt/GruntPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.moowork.gradle.grunt | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class GruntPlugin implements Plugin<Project> | ||
{ | ||
@Override | ||
void apply( final Project project ) | ||
{ | ||
project.extensions.getExtraProperties().set('GruntTask', GruntTask.class); | ||
project.tasks.create( NpmInstallTask.NAME, NpmInstallTask ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.moowork.gradle.grunt | ||
|
||
import org.apache.tools.ant.taskdefs.condition.Os | ||
import org.gradle.api.tasks.Exec | ||
|
||
class GruntTask extends Exec | ||
{ | ||
public GruntTask( ) | ||
{ | ||
setGroup( "Grunt" ); | ||
setDependsOn( [] ); | ||
determineExecutable(); | ||
} | ||
|
||
private void determineExecutable( ) | ||
{ | ||
String gruntExec = "grunt"; | ||
if ( Os.isFamily( Os.FAMILY_WINDOWS ) ) | ||
{ | ||
gruntExec = gruntExec + ".cmd"; | ||
} | ||
|
||
File localGrunt = project.file( "node_modules/grunt-cli/bin/${gruntExec}" ); | ||
if ( localGrunt.isFile() ) | ||
{ | ||
gruntExec = localGrunt.toString(); | ||
} | ||
|
||
setExecutable( gruntExec ); | ||
} | ||
|
||
@Override | ||
void setDependsOn( final Iterable<?> dependsOn ) | ||
{ | ||
List list = dependsOn as List; | ||
list.add( NpmInstallTask.NAME ); | ||
|
||
super.setDependsOn( list ) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/groovy/com/moowork/gradle/grunt/NpmInstallTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.moowork.gradle.grunt | ||
|
||
import org.gradle.api.tasks.Exec | ||
|
||
class NpmInstallTask extends Exec | ||
{ | ||
public final static NAME = 'npmInstall'; | ||
|
||
public NpmInstallTask( ) | ||
{ | ||
setGroup( "Grunt" ); | ||
setExecutable( "npm" ); | ||
setArgs( ["install"] as List ); | ||
getInputs().file( "package.json" ); | ||
getOutputs().dir( "node_modules" ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
implementation-class=com.moowork.gradle.grunt.GruntPlugin |