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 8569445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:20:10+00:00 2026-06-11T18:20:10+00:00

This seems like a simple task in Buildr, so I must be missing something

  • 0

This seems like a simple task in Buildr, so I must be missing something obvious because I can’t make it work. Suppose I have a directory with two files, like so:

test/lib/src/main/scala/MyLib.scala
test/app/src/main/scala/MyApp.scala

MyLib.scala is:

class MyLib {
  def hello() { println("Hello!") }
}

And MyApp.scala is:

object MyApp extends App {
  val ml = new MyLib
  ml.hello()
}

Building these with scalac is straightforward:

$ cd test
$ scalac lib/src/main/scala/MyLib.scala -d target/main/classes
$ scalac app/src/main/scala/MyApp.scala -cp target/main/classes -d target/main/classes
$ cd target/main/classes/
$ scala MyApp
Hello!

However, my naïve attempt to turn this into a Buildfile (in the test folder):

require 'buildr/scala'

lib_layout = Layout.new
lib_layout[:source, :main, :scala] = 'lib/src/main/scala'
app_layout = Layout.new
app_layout[:source, :main, :scala] = 'app/src/main/scala'

define 'mylib', :layout => lib_layout do
end

define 'myapp', :layout => app_layout do
  compile.with project('mylib')
end

fails with:

(in /test, development)
Building mylib
Compiling myapp into /test/target/main/classes
/test/app/src/main/scala/MyApp.scala:2: error: not found: type MyLib
  val ml = new MyLib
               ^
one error found
Buildr aborted!
RuntimeError : Failed to compile, see errors above

and if I run buildr --trace it’s pretty clear that the reason scalac is failing is because the classpath does not include target/main/classes.

How do I make this happen? I know that separating the two projects may seem contrived, but I have something much more sophisticated in mind, and this example boiled the problem down to its essential components.

  • 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-11T18:20:11+00:00Added an answer on June 11, 2026 at 6:20 pm

    The idiomatic way to describe your project with Buildr would be to use sub-projects,

    Note: buildfile below goes into the test/ directory.

    require 'buildr/scala'
    
    define "my-project" do
      define "lib" do
      end
    
      define "app" do
        compile.with project("lib").compile.target
      end
    end
    

    The two sub-projects lib and app are automatically mapped to the lib/ and app/ sub-directories and Buildr will automatically look for sources under src/main/scala for each.

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

Sidebar

Related Questions

This situation seems like it should be a simple task but I can't come
this seems like a simple enough question but I can't seem to find a
This seems like a really simple task, so bear with me. I'm trying to
This seems like such a simple task, but I'm having a hard time finding
This seems like a simple and common task, but we cannot get it to
This seems like it should be a simple task, but I'm a noob as
Although this seems like a simple task, I need to change the background color
Apologies in advance. This seems like a simple task, but hours later on Google
This seems like a simple task or a repeat, but bear with me-- I've
This seems like a simple task but there may be an easier way. I

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.