1

I have a Play 2.2 Application which strickly used only to implement REST API.

I have in an independent GIT repo a AngularJS application. This application uses Grunt and NodeJS to do the build.

The Result of the frontend application is an index.html + 1 js file and 1 css file.

Ideally I would like to invoke the Grunt build script from SBT which builds the angularjs app.

Is there a SBT plugin I can use to do this ?

What is the best approach I should use to do this the most simple way ?

At the moment I build it manually and copy the static resources into my PLAY's public folder.

Thanks in advance

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
Istvano
  • 992
  • 1
  • 12
  • 19

1 Answers1

0

I've never done it before, but a quick Google search gave me sbt-grunt-plugin whose the last commit was authored on Feb 20, 2013 :(

The plugin is a bit outdated, but is doing what I'd propose -- offers a command (could also be a task) that wraps grunt (as the plugin above does). You may also want to read the official documentation of sbt about Commands.

I would then declare a dependency on the angularjs/frontend project using RootProject for the root project with frontend (angularjs) and backend (Play Framework) submodules - see How can sbt pull dependency artifacts from git?:

lazy val frontend = RootProject(uri("git://..."))

lazy val backend = project ...

The root project is auto-created by sbt as described in Default root project:

If a project is not defined for the root directory in the build, sbt creates a default one that aggregates all other projects in the build.

frontend would need to have build.sbt with the task created and it should work fairly well (it might be the only viable solution to not tie the projects too much and create unnecessary inter-dependencies).

Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Thanks, sbt-grunt-plugin looks good. Unfortunatelly the dependent project is not an SBT one / nor a Play one. Is it still worth using SBT RootProject to fetch it from Git ? – Istvano Aug 19 '14 at 07:35
  • The idea is to `git clone` it at build time and execute `grunt` within. It's possible without converting the other project to an sbt-managed one. What command would you like to run in the frontend project? – Jacek Laskowski Aug 19 '14 at 09:00