Open joaoduraes opened 9 years ago
Here's my pom.xml config:
<plugin>
<groupId>pl.allegro</groupId>
<artifactId>grunt-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<gruntExecutable>node_modules/grunt-cli/bin/grunt</gruntExecutable>
<runGruntWithNode>true</runGruntWithNode>
<sourceDirectory>src/main</sourceDirectory>
<jsSourceDirectory>app</jsSourceDirectory>
<!-- example options usage to get verbose output in logs -->
<gruntOptions>
<gruntOption>--verbose</gruntOption>
</gruntOptions>
<!-- example npm install env variable -->
<npmEnvironmentVar>
<PHANTOMJS_CDNURL>http://cnpmjs.org/downloads</PHANTOMJS_CDNURL>
</npmEnvironmentVar>
<!-- example options usage to filter variables in given resource -->
<filteredResources>
<filteredResource>maven-properties.json</filteredResource>
</filteredResources>
</configuration>
<executions>
<execution>
<goals>
<goal>create-resources</goal>
<goal>npm</goal>
<!-- or npm-offline if npm failure is not an option -->
<goal>bower</goal>
<goal>grunt</goal>
</goals>
</execution>
</executions>
</plugin>
Hi,
I've heard it's related to permission, but I cannot get it to work even with sudo.
Have you got any progress on this?
When I run grunt from the source folder it works.
Regards
The configuration is pretty standard, so i would rather look at generated stuff. If you run grunt from target-grunt
, does it fail?
I'm sorry I haven't updated this issue, but after a while I figured out it was some problem with my local environment. After deleting a node_modules folder that had been previously generated it all went fine.
I hope this helps.
ah :) Thats great to hear!
So we only need to solve @eduardoarantes problem now.
I tried to run grunt
from target-grunt
and I got the same error in a different fashion
Running "imagemin:build" (imagemin) task Fatal error: spawn EACCES
I've also tried with root user and I've got another error.
[INFO] [INFO] --- grunt-maven-plugin:1.5.0:bower (default) @ ROOT --- [INFO] OS Name: Mac OS X bower ESUDO Cannot be run with sudo
Additional error details: Since bower is a user command, there is no need to execute it with superuser permissions. If you're having permission errors when using bower without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
http://www.joyent.com/blog/installing-node-and-npm https://gist.github.com/isaacs/579814
You can however run a command with sudo using --allow-root option [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE
running Maven with -e switch I get this info
[ERROR] Failed to execute goal pl.allegro:grunt-maven-plugin:1.5.0:grunt (default) on project ROOT: Unable to execute mojo: Command execution failed. Process exited with an error: 3 (Exit value: 3) -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal pl.allegro:grunt-maven-plugin:1.5.0:grunt (default) on project ROOT: Unable to execute mojo at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to execute mojo at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojoImpl(MojoExecutor.java:174) at org.twdata.maven.mojoexecutor.MojoExecutor$ExecutionEnvironmentM3.executeMojo(MojoExecutor.java:476) at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo(MojoExecutor.java:75) at pl.allegro.tdr.gruntmaven.AbstractExecutableMojo.runExecutable(AbstractExecutableMojo.java:97) at pl.allegro.tdr.gruntmaven.AbstractExecutableMojo.executeInternal(AbstractExecutableMojo.java:86) at pl.allegro.tdr.gruntmaven.BaseMavenGruntMojo.execute(BaseMavenGruntMojo.java:96) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed. at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:362) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.twdata.maven.mojoexecutor.MojoExecutor.executeMojoImpl(MojoExecutor.java:172) ... 27 more Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 3 (Exit value: 3) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377) at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160) at org.codehaus.mojo.exec.ExecMojo.executeCommandLine(ExecMojo.java:610) at org.codehaus.mojo.exec.ExecMojo.execute(ExecMojo.java:352) ... 29 more
I think this is something with grunt build itself, i would not involve maven here - it's reproducable when running pure grunt from target-grunt
. I suppose you tried deleting target-grunt altogether and retrying the build?
Adam,
I does happen when I run grunt on the target-grunt
but it doesn't happen when I run in the source directory.
It's weird.
Any suggestion? Anything else to check?
Regards, Eduardo
I managed to get it to work
Instead of having the grunt running on the target-grunt
folder, I put it to run in the source folder directly.
I have the same problem. I suspect the create-resources copies the resources without preserve permissions. Therefor the imagemin cannot execute the binary because *nix systems require the +x permission in order to execute the binary.
I only work on OS X and Linux systems. I asked a co-worker to build the project on Windows and it did build successfully. Windows systems do not require a permission on a .exe file.
Regards,
Pieter
I managed to get it working, it is a executable permission problem! The executable files do not have execute rights.
Workaround: copy the sources with antrun and disable the create-resources goal pom.xml snippet:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-resources-grunt</id>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete dir="${project.basedir}/target-grunt"/>
<!--<copy todir="${project.basedir}/target-grunt">-->
<!--<fileset dir="${project.basedir}/src/main/dashboard"/>-->
<!--</copy>-->
<exec executable="cp">
<arg value="-r"/>
<arg value="-p"/>
<arg value="${project.basedir}/src/main/dashboard"/>
<arg value="${project.basedir}/target-grunt"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.allegro</groupId>
<artifactId>grunt-maven-plugin</artifactId>
<configuration>
<sourceDirectory>${project.basedir}/src</sourceDirectory>
<jsSourceDirectory>main/dashboard</jsSourceDirectory>
</configuration>
<executions>
<execution>
<goals>
<!--<goal>create-resources</goal>-->
<goal>npm</goal>
<goal>bower</goal>
<goal>grunt</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Hm, okay, but will it work on any other platform than Unix? I could replace create-resources with this one, but dont have access to Windows machine.
You could create two ant targets one for windows and one for nix systems. With antrun you kan read the environment and execute the current tasks for nix systems and execute:
<copy todir="${project.basedir}/target-grunt">
<fileset dir="${project.basedir}/src/main/dashboard"/>
</copy>
in the windows target.
I do not have an example laying around but check ant documentation and stackoverflow how to do that.
I already have the diff for *nix and Windows systems, so yeah, that might do it.
Handy, could you paste your pom.xml snippet when you have it running. We have developers that run in Windows (they are almost extinct) over here :) But they would really appreciate your implementation!
Oh, i have it in plugin code, never tried to use it in pom, but its based on ${os.name}
variable, which you could probably use to build profiles. Anyways i will try to incorporate your fix into the plugin itself, so you might not need to expand your pom :)
Super! When you are done we wil remove the complete workaround!
What's the status of this? I'm encountering a very similar issue, but using npm-offline
. If I unpack the tar myself and run npm rebuild
, executables seem to run properly. If I let grunt-maven-plugin do this, they don't.
After some trials, I'm almost certain it has to do with the tar unpack.
Hi!
I am having the following issue when running mvn clean install:
If I just run the grunt build, the imagemin task runs just fine without any issues, but when running within the maven build it doesn't seem to be able to run. I also have the svgmin grunt task running and this doesn't have any problems.
Everyone seem to point to permissions problems, but I don't think that's the case here as I can run the imagemin task just fine if not from the maven build.
Any idea?
Thanks in advance.