Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default mainClass not picked up #568

Closed
francisdb opened this issue Apr 30, 2015 · 6 comments
Closed

default mainClass not picked up #568

francisdb opened this issue Apr 30, 2015 · 6 comments

Comments

@francisdb
Copy link
Contributor

My module has multiple classes containing a main method. The documentation mentions this:
This archetype will use the mainClass setting of sbt (automatically discovers your main class)

So I tried all kinds of things like:

    mainClass in (Compile, run) := Some("foo.bar.Main"),
    mainClass in (Compile, packageBin) := Some("foo.bar.Main"),
    mainClass in Universal := Some("foo.bar.Main")

The first one works for run and re-start but the packager is not picking up the default main class. The binaries are missing and I always get this logged:

Multiple main classes detected. Run 'show discoveredMainClasses' to see the list

(I'm using a multi-module build, this module is has enablePlugins(JavaAppPackaging))

@muuki88
Copy link
Contributor

muuki88 commented May 1, 2015

Setting the mainClass like this?

mainClass in Compile := Some("foo.bar.Main"),

If this doesn't help, can you provide a small example project demonstrating the issue?

@francisdb
Copy link
Contributor Author

Ok, now I feel stupid. Just tried this and it works. Maybe something to add to the docs?

@muuki88
Copy link
Contributor

muuki88 commented May 1, 2015

no problem ;) actually you used the most specific configuration possible. SBT beginners normally don't know this. Configuring on Configuration and Task axis.

What are you trying to achieve? Normally you should have one entry point in your application. If you have different application, splitting them up in submodules is usually the best way as sbt configures most of the stuff itself.

However a small section on Advanced Topics wouldn't hurt. Do you have time for a small pull request on the topic?

@francisdb
Copy link
Contributor Author

In fact the second main class in my application was inherited from some library. I do have multiple modules with each it's own java app / server and if I remember correctly I had a problem with the sbt-revolver plugin in the past and as a solution for that I added the (Compile, run)

Anyway it all works perfectly now. I'll submit a small patch for the docs. No need for a advanced topic?

muuki88 added a commit that referenced this issue May 1, 2015
updated docs related to #568 on multiple main classes
@muuki88
Copy link
Contributor

muuki88 commented May 1, 2015

awesome :)

@francisdb
Copy link
Contributor Author

oops, there's a typo, produces instead of produced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants