0

I have a little web app using Spring Boot and Angular 1, Maven and Wro4j, and I want to give a try to Angular 2, which I am completely new in.

I use Maven/Wro4j 1.8.0 to minify at compile time and get a single js file for angular dependencies, which I then use in my index.html header. While it worked with my angular 1 app, minifying fails now. I use jsMin as a processor. It fails when handling webjar:angular__compiler/2.1.1/bundles/compiler.umd.js.

Digging in the wro4j doc, I found the ngAnnotate processor, which may be the solution to my problem. But I got two more issues there:

  • I added ng-annotate 1.2.1 to my pom.xml (wro4j dependencies) but it fails because of an unsatisfied transitive dependency to acorn (ng-annotate 1.2.1 pom depends on acorn [2.6.4,2.7), and there is no such version on Maven central). To circumvemt this, I edited the ng-annotate pom to use acorn 2.7.0, which may not be the best solution.
  • After getting my dependency OK and adding ngAnnotate to the processors list (before jsMin), I get this error message:

processor is not supported on this environment

It seems that it tries to run ng-annotate and does not find it. The Wro4j documentation states that "The implementation assume the required npm is installed". I thought (wrongly, it seems) that adding the ng-annotate webjar to the pom would be enough. What did I miss?

Note: I would really like to go on letting Maven handle all the configuration (Java and Js), which worked before, instead of switching to a js dependency solution. I never used any npm command, nor grunt, nor bower, and never needed it so far.

Steph
  • 1,989
  • 14
  • 18

1 Answers1

1

The way wro4j works with ng-annotate, it simply executes the command ng-annotate in the project folder.

So it is probably due to your PATH variable that is not configured correctly and that does not reference the folder that contains ng-annotate whether you install it through webjar or npm.

For example, if you use Eclipse Configurations, you can re-set the PATH variable in the "Environment" tab.

To figure out the right path: For webjar, do a search on where the ng-annotate npm executable is extracted. For NPM, open a terminal, see if ng-annotate works (it has to be installed globally with npm install -g ng-annotate) and then display env variable: echo $PATH or the path of the executable: which ng-annotate.

I had the same error and in my case, Maven did not have /usr/local/bin referenced in the PATH.

damien
  • 33
  • 5
  • Thanks for this answer. I had completely given up on this subject. I dunno when I will have time to try this, but in the meantime you deserve a +1 for resurrecting this post ^^. – Steph Feb 01 '17 at 19:35