Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8119971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:58:35+00:00 2026-06-06T04:58:35+00:00

We have one main project and two subprojects. One of the subprojects is the

  • 0

We have one main project and two subprojects. One of the subprojects is the playframework which has a “unique” build structure. How can I override the source directories BUT only for that one subproject such that all other projects are using the standard layout of source directories src/main/java, etc.

I tried the first answer which is not working and for my directory structure

 stserver
     build.gradle (1)
     project1
     webserver
         build.gradle (2)

The 2nd gradle file is this

sourceSets.main{
  java.srcDirs = ['app']
}

task build << {
  println "source sets=$sourceSets.main.java.srcDirs"
}

When I run this, it prints out stserver/app as my srcDir instead of stserver/webserver/app???? What am I doing wrong here?

thanks,
Dean

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:58:36+00:00Added an answer on June 6, 2026 at 4:58 am

    Please have a look at the docs Peter has suggested. I have a ready build.gradle that I have working with Play Framework 2.0~, so I’ll share it here in hope you’ll find some useful setup tips.

    My project structure:

    +- master/
      +- build.gradle  <-- contains common setup, 
                           and applies 'java' plugin to all subprojects
    +- ui/             <-- project using Play framework
      +- build.gradle  <-- excerpt from this file is posted below
    

    The excerpt from build.gradle

    repositories{
      maven{
        //Play dependencies will be downloaded from here
        url " http://repo.typesafe.com/typesafe/releases"
      }
    }
    
    //Optional but useful. Finds 'play' executable from user's PATH
    def findPlay20(){
      def pathEnvName = ['PATH', 'Path'].find{ System.getenv()[it] != null }
      for(path in System.getenv()[pathEnvName].split(File.pathSeparator)){
        for(playExec in ['play.bat', 'play', 'play.sh']){
          if(new File(path, playExec).exists()){
            project.ext.playHome = path
            project.ext.playExec = new File(path, playExec)
            return
          }
        }
      }
      throw new RuntimeException("""'play' command was not found in PATH.
    Make sure you have Play Framework 2.0 installed and in your path""")
    }
    
    findPlay20()
    
    configurations{
      //Configuration to hold all Play dependencies
      providedPlay
    }
    
    dependencies{
      providedPlay "play:play_2.9.1:2.0+"
      //Eclipse cannot compile Play template, so you have to tell it to
      //look for play-compiled classes
      providedPlay files('target/scala-2.9.1/classes_managed')
    
      //other dependencies
    }
    
    sourceSets.main{
      java.srcDirs = ['app', 'target/scala-2.9.1/src_managed/main']
      //Make sure Play libraries are visible during compilation
      compileClasspath += configurations.providedPlay
    }
    
    //This task will copy your project dependencies (if any) to 'lib'
    //folder, which Play automatically includes in its compilation classpath
    task copyPlayLibs(type: Copy){
      doFirst { delete 'lib' }
      from configurations.compile
      into 'lib'
    }
    
    //Sets up common play tasks to be accessible from gradle.
    //Can be useful if you use gradle in a continuous integration 
    //environment like Jenkins.
    //
    //'play compile' becomes 'gradle playCompile'
    //'play run' becomes 'gradle playRun', and so on.
    [ ['run',     [copyPlayLibs]],
      ['compile', [copyPlayLibs]],
      ['clean',   []],
      ['test',    []],
      ['doc',     [copyPlayLibs]],
      ['stage',   [copyPlayLibs]] ].each { cmdSpec ->
        def playCommand = cmdSpec[0]
        def depTasks = cmdSpec[1]
        task "play${playCommand.capitalize()}" (type: Exec,
                                                dependsOn: depTasks,
                                                description: "Execute 'play ${playCommand}'") {
         commandLine playExec, playCommand
        }
    }
    
    //Interate playClean and playCompile task into standard
    //gradle build cycle
    clean.dependsOn "playClean"
    [compileScala, compileJava]*.dependsOn "playCompile"
    
    //Include Play libraries in Eclipse classpath
    eclipse {
      classpath {
        plusConfigurations += configurations.providedPlay
      }
    }
    

    Note: I have just extracted the above from an existing bigger gradle file, so it might be missing some things, so no guarantees:) Hope it’s useful anyway. Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project which has a calling structure similar to this: main project/application
I have one main page in my Silverlight project. I have two frame inside
My C# WinForms solution has two projects. A DLL which is the main project
I have the standard setup of one main image and multiple thumbnails which can
In my 'project/repo' I have two MS Visual Studio projects, one for the main
I have a subdirectory structure in my project with two cmake files. One of
I have an Android project with two activities. One is my main activity, using
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div
I have one main array which is the returned data from a MySQL query
I have a one main Workflow which calls several activities asynchronously. Some of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.