Cool, so it's definitely my task and agree with everything you are saying 
regarding the PATH being the issue.

I guess that leaves the question of what changed to cause the PATH to 
differ from the terminal in 0.4 and above? I'll have a look and see if I 
can find out a way to get grunt to run.


On Wednesday, 12 February 2014 16:13:42 UTC, Xavier Ducrohet wrote:
>
> The Android plugin uses a LOT of command line tools (aapt, dx, aidl, 
> zipalign, renderscript compiler, ...) so it's obviously possible.
>
> In your case, I'm guessing it might not be a working dir issue actually, 
> but a path issue. It might simply not find grunt.
>
> I'm guessing somehow the path my be inherited from the terminal when 
> running from the command line, but when running from Studio the custom PATH 
> might not be configured.
>
>
> On Wed, Feb 12, 2014 at 5:59 AM, Matt Gaunt <[email protected]<javascript:>
> > wrote:
>
>> So if I can't assume the working directory and I can't change the working 
>> directory (Despite there be an option to do so with the exec task), is it 
>> not possible to run tasks on the command line?
>>
>> It also still confuses me how I can get this to run on the CLI with the 
>> gradle wrapper, but not Android Studio.
>>
>> Just an FYI, changing the task to the following:
>>
>> task buildWebApp(type: Exec) {
>>     workingDir 
>> '/Users/matt/Programming/Workspace/webview-browser/BrowserPages/'
>>
>>     //on windows:
>>     commandLine 'grunt.exe', 'build'
>>
>>      //on linux
>>     commandLine 'grunt', 'build'
>> }
>>
>> Will run with ./gradlew buildWebApp but fails in Android Studio. 
>>
>> Has anyone managed to execute shell scripts or other command line tools 
>> via Gradle run in Android Studio?
>>
>> On Wednesday, 12 February 2014 00:51:59 UTC, Luke Daley wrote:
>>
>>> Just chiming in on why Gradle doesn't allow you to set the working 
>>> directory… 
>>>
>>> The JVM doesn't support changing the working directory mid process. It 
>>> can be done with JNA/JNI (and Gradle does do this under certain 
>>> circumstances), but it's problematic to use extensively. Regardless, 
>>> relying on the working directory in any sense is inherently fragile. 
>>>
>>> > Xavier Ducrohet <mailto:[email protected]> 
>>> > 12 February 2014 4:57 am 
>>> > We actually had a discussion about this recently. 
>>> > The tooling api doesn't allow you to set the working dir so it's not 
>>> > possible. 
>>> > 
>>> > Your build script really shouldn't make any assumption regarding the 
>>> > working directory. 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > Xavier Ducrohet 
>>> > Android SDK Tech Lead 
>>> > Google Inc. 
>>> > http://developer.android.com | http://tools.android.com 
>>> > 
>>> > Please do not send me questions directly. Thanks! 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "adt-dev" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> > an email to [email protected]. 
>>> > For more options, visit https://groups.google.com/groups/opt_out. 
>>> > Scott Barta <mailto:[email protected]> 
>>> > 12 February 2014 2:45 am 
>>> > Is there some issue with your paths that it now can't find the 
>>> > command? Perhaps you should give it a fully-qualified path to the 
>>> > grunt executable. Also, do you have the same problems on all 
>>> platforms? 
>>> > 
>>> > When you execute Gradle tasks from Android Studio, it doesn't make an 
>>> > attempt to set the working directory, though I don't know that it's 
>>> > changed in recent versions -- that might also be something to 
>>> investigate. 
>>> > 
>>> > 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "adt-dev" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> > an email to [email protected]. 
>>> > For more options, visit https://groups.google.com/groups/opt_out. 
>>> > Matt Gaunt <mailto:[email protected]> 
>>> > 12 February 2014 2:00 am 
>>> > Hey everyone, 
>>> > 
>>> > Since updating to 0.4, I've been able to run command line tools from 
>>> > gradle. 
>>> > 
>>> > I used to have the following gradle build task: 
>>> > 
>>> > |task buildWebApp(type:  Exec)  { 
>>> >      executable=  Os.isFamily(Os.FAMILY_WINDOWS)  ?  "grunt.cmd"  : 
>>>  "grunt" 
>>> > 
>>> >      args=  ["build"] 
>>> > }| 
>>> > 
>>> > This would pick the appropriate grunt command and run it with the 
>>> > argument "build". 
>>> > 
>>> > This worked without any kind of issue 
>>> > 
>>> > In Android Studio 0.4, using Gradle 1.9 and it's no longer working. 
>>> > Instead I get the following error: 
>>> > 
>>> >     Execution failed for task ':BrowserPages:buildWebApp'. A problem 
>>> >     occurred starting process 'command 'grunt'' 
>>> > 
>>> > Normally at this point I would debug with gradlew, but running the 
>>> > following command, throws no errors: 
>>> > 
>>> >     $ ./gradlew buildWebApp 
>>> > 
>>> > I've also tried running the full task list to still not find any 
>>> problems. 
>>> > 
>>> > The way this is executed is from my main build.gradle file with this 
>>> > dependency 
>>> > 
>>> >     copyWebApplication.dependsOn ':BrowserPages:buildWebApp' 
>>> > 
>>> > Anyone have any ideas? 
>>> > 
>>> > I've tried to run executable = "node" with arg = ["-v"] and get the 
>>> > same error where it can't find node. Node is globally accessible on my 
>>> > terminal, so I can only assume that the command is being run in a 
>>> > different environment to the terminal. There is the option for setting 
>>> > the environment on the task but I can't find any examples of how it 
>>> > should be used. 
>>> > 
>>> > -- 
>>> > You received this message because you are subscribed to the Google 
>>> > Groups "adt-dev" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> > an email to [email protected]. 
>>> > For more options, visit https://groups.google.com/groups/opt_out. 
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "adt-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> -- 
> Xavier Ducrohet
> Android SDK Tech Lead
> Google Inc.
> http://developer.android.com | http://tools.android.com
>
> Please do not send me questions directly. Thanks! 
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to