Play app with Maven project layout doesn't compile for Gradle plugin

gradle

(Iana Bondarska) #1

Hi,
I’m creating Scala Play app with Gradle (gradle version 2.6.21, gradle 5.2, scala 2.12).
I’d like to use Maven project layout:

src
└ main
   └ scala
         └ com.mypackage
               └ MyController.scala

I use 'org.gradle.playframework' version '0.2' plugin. I’ve added following configuration for play plugin to gradle.build file:

play{
platform play: 2.6.21, scala: 2.12, java: JavaVersion.VERSION_1_9
sourceSets {
  main {
     scala {
       source.setSrcDirs files("src/main/scala")
    }
    resources{
      source.setSrcDirs files("src/main/resources") 
   }
  }}
}

in routes file I specify 1 route:

GET attribute/:attributeId com.mypackage.MyController.getObject(attributeId Long)

When I run compileScala task - I get an exception:

object MyController is not a member of package com.mypackage

Could you tell me please, is there a way to configure Gradle play plugin to work with maven project layout?


(Marcos Pereira) #2

Hey @yana2301,

Not sure exactly which plugin you are using, but the way you configure additional source folders is describe here in Gradle docs:

https://docs.gradle.org/current/userguide/play_plugin.html#example_configuring_extra_source_sets_to_a_play_application

And also the example a little below the same page:

https://docs.gradle.org/current/userguide/play_plugin.html#example_adding_extra_source_sets_to_a_play_application

Best.