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

Propagate main class defined from the sbt build #718

Closed
tindzk opened this issue Nov 14, 2018 · 4 comments
Closed

Propagate main class defined from the sbt build #718

tindzk opened this issue Nov 14, 2018 · 4 comments
Labels
configuration format Assigned to any ticket or pull request that will change the configuration file format. enhancement help wanted integrations sbt

Comments

@tindzk
Copy link
Contributor

tindzk commented Nov 14, 2018

As per #716, the detection of main classes is restricted to classes defined within the project. In the case of Play, the sbt project already sets the main class correctly:

[play-scala-seed] $ show mainClass
[info] Some(play.core.server.ProdServerStart)

It would be useful to use this value and set it in the Bloop configuration file such that it does not have to be passed as a command-line parameter.

@jvican jvican changed the title Detect main class in sbt plug-in Propagate main class defined in the sbt build Nov 14, 2018
@jvican jvican changed the title Propagate main class defined in the sbt build Propagate main class defined from the sbt build Nov 23, 2018
@jvican
Copy link
Contributor

jvican commented Nov 23, 2018

@tindzk Do you feel like taking a stab at this? Should take only a few minutes 😄

@tindzk
Copy link
Contributor Author

tindzk commented Nov 23, 2018

Sure, I will have a look.

@jvican jvican added the configuration format Assigned to any ticket or pull request that will change the configuration file format. label Nov 23, 2018
@jvican
Copy link
Contributor

jvican commented Nov 23, 2018

@tindzk Great! The configuration field for the main class is already there, we just need to propagate it with something like:

        val jvmConfig = Config.JvmConfig(Some(javaHome.toPath), javaOptions.toList)
        val mainClass = Keys.mainClass.in(config).value
        Config.Platform.Jvm(jvmConfig, mainClass)

where config == Keys.configuration.value. We should probably also do the same for Gradle, Maven and mill if we're not doing it there, and add tests for gradle and sbt (in sbt, you can add a check in one of the scripted tests that checks the contents of the JSON configuration files).

tindzk added a commit to tindzk/bloop that referenced this issue Nov 25, 2018
jvican pushed a commit to tindzk/bloop that referenced this issue Nov 29, 2018
@jvican
Copy link
Contributor

jvican commented Nov 29, 2018

We cannot depend on mainClass directly in sbt because it forces the compilation of projects (internally, mainClass depends on discoveredMainClasses which triggers compilation during bloopInstall, which makes the process slow).

As there is no way to avoid that in sbt, I've introduced a bloopMainClass setting that can be set just as mainClass and that users can use to avoid duplicating the main class every time they want to run an application. There is no better solution than this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration format Assigned to any ticket or pull request that will change the configuration file format. enhancement help wanted integrations sbt
Projects
None yet
Development

No branches or pull requests

2 participants