webappResources in package := Seq(baseDirectory.value ....) throws Error parsing expression

255 views Asked by At

I try to configure sbt (version 0.9.0) to use webapp/dist as the webappResource directory when running package task in sbt, and webapp/app as the webappResource directory when running the container:start command, following this description:

How to have different webapp resources for container:start and package tasks in SBT

But it throws the following error:


    error: eof expected but 'package' found.
    webappResources in package := Seq(baseDirectory.value / "webapp" / "dist") 
                       ^
    [error] Error parsing expression.

I guess that package is a reserved word also in sbt conf file, any other way to override setting in package task?

The reason for doing this is that I use gulp to manage webclient. Gulp runs the project from app folder, and compiles (minification etc.) the webclient project into dist folder. When I develop, I use the webapp/app folder as declared below:


    webappResources in Compile := Seq(baseDirectory.value / "webapp" / "app")

When I create a release, I first build (minification etc.) the webapp client into webapp/dist using gulp. Then I want to package webapp/dist content into the final war.

But I am not able to override the setting above to use webapp/dist, when using the package task.

I have also tried to create my own configuration like this:


    webappResources in Compile := Seq(baseDirectory.value / "src" / "main" / "webapp" / "app")

    lazy val ReleaseWarConfig = config("release-war") extend (Compile)

    val root = (project in file(".")).
      configs(ReleaseWarConfig).
      settings(inConfig(ReleaseWarConfig)(webSettings): _*).
      settings(
        webappResources in Compile := Seq(baseDirectory.value/"src"/"main"/"webapp"/"dist")
    )
    // I have also tried webappResources in ReleaseConfig instead of Compile ..

But it still uses the webapp/app directory instead of webapp/dist directory.

Any help would be very much appreciated !!!!

1

There are 1 answers

2
earldouglas On

What is the directory layout of your project? It sounds like you have your Web application resources directory at [myproject]/webapp/dist/, meaning you have WEB-INF/ and WEB-INF/web.xml (and various other optional resources) under [myproject]/webapp/dist/ as well. Is this correct?

To set the location of your Web application resources directory to [myproject]/webapp/dist/, add the following setting to your sbt configuration:

build.sbt:

webappSrc in webapp <<= (baseDirectory in Compile) map  { _ / "webapp" / "dist" }

You can read more about this setting in the readme.