Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously we recomended rerunning another import for maven workspace…
…s, which would not help. Now we include a link to the new documentation page about maven. We also added additional gradle and mill documentation.
- Loading branch information
Showing
5 changed files
with
232 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
id: gradle | ||
title: Gradle | ||
--- | ||
|
||
Gradle is a build tool that can be used easily with a large number of | ||
programming languages including Scala. Using it you can easily define your | ||
builds using Groovy or Kotlin, which enables for a high degree of customization. | ||
You can look up all the possible features on the | ||
[Gradle website](https://gradle.org/). | ||
|
||
## Automatic installation | ||
|
||
The first time you open Metals in a new workspace it prompts you to import the | ||
build. Select "Import build" to start automatic installation. After it's | ||
finished you should be able edit and compile your code. | ||
|
||
## Manual installation | ||
|
||
In a highly customized workspaces it might not be possible to use automatic | ||
import. In such cases there is a number of steps required to generate the needed | ||
Bloop config. | ||
|
||
First we need to add the Bloop plugin dependency to the project, it should be | ||
included in the buildscript section: | ||
|
||
```groovy | ||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath 'ch.epfl.scala:gradle-bloop_2.11:@@BLOOP_VERSION@@' | ||
} | ||
} | ||
``` | ||
|
||
Secondly, we need to enable the plugin for all the projects we want to include, | ||
it's easiest to define it for `allprojects`: | ||
|
||
```groovy | ||
allprojects { | ||
apply plugin: bloop.integrations.gradle.BloopPlugin | ||
} | ||
``` | ||
|
||
Now we can run `gradle bloopInstall`, which will create a Bloop configuration | ||
files. This will enable us to work with Metals and most features will work, but | ||
for everything to work properly we need to also add the SemanticDB plugin. This | ||
can be done by adding a couple of options to the scala compiler: | ||
|
||
```groovy | ||
allprojects { | ||
afterEvaluate { | ||
configurations { | ||
scalaCompilerPlugin | ||
} | ||
dependencies { | ||
scalaCompilerPlugin "org.scalameta:semanticdb-scalac_$scalaVersion:@@SCALAMETA_VERSION@@" | ||
} | ||
def pluginFile = project.configurations.scalaCompilerPlugin.find { | ||
it.name.contains("semanticdb") | ||
} | ||
if (!pluginFile) { | ||
throw new RuntimeException("SemanticDB plugin not found!") | ||
} | ||
tasks.withType(ScalaCompile) { | ||
def params = [ | ||
'-Xplugin:' + pluginFile.absolutePath, | ||
'-P:semanticdb:synthetics:on', | ||
'-P:semanticdb:failures:warning', | ||
'-P:semanticdb:sourceroot:' + project.rootProject.projectDir, | ||
'-Yrangepos', | ||
'-Xplugin-require:semanticdb' | ||
] | ||
if (scalaCompileOptions.additionalParameters) | ||
scalaCompileOptions.additionalParameters += params | ||
else | ||
scalaCompileOptions.additionalParameters = params | ||
} | ||
} | ||
} | ||
``` | ||
|
||
You need to also define `scalaVersion` which corresponds to the scala version in | ||
your project. We also use afterEvaluate here so that we have scala dependency | ||
and all build specific scala compiler options defined before adding the | ||
SemanticDB plugin. It might be not needed in your project depending on the | ||
specifics. | ||
|
||
Now you can rerun `gradle bloopInstall` to have a properly configured SemanticDB | ||
plugin in Bloop config. | ||
|
||
This is much more complex than in case of the automatic installation, so it is | ||
recommended to only do manual installation in case of problems with the | ||
automatic one. You can also always try to reach us on the Metals gitter channel | ||
in case of any problems. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
id: maven | ||
title: Maven | ||
--- | ||
|
||
Maven is one of the most common build tools in the JVM ecosystem and it also | ||
allows for using scala through the | ||
[scala-maven-plugin](https://davidb.github.io/scala-maven-plugin/usage.html). | ||
The [scalor-maven-plugin](https://github.com/random-maven/scalor-maven-plugin) | ||
is not supported, see \$LINK for more information. | ||
|
||
## Automatic installation | ||
|
||
The first time you open Metals in a new workspace it prompts you to import the | ||
build. Select "Import build" to start automatic installation. | ||
|
||
This will create all the needed Bloop files, however there will be a warning, | ||
since the SemanticDB plugin was not added yet in the automatic import. This will | ||
be added later. Most features should work without it, however some require | ||
SemanticDB files to be provided alongside compiled data. To do that we need a | ||
couple of steps that are explained in the manual installation section. | ||
|
||
## Manual instalation | ||
|
||
First, we need to add a couple of options to the Scala compiler in the | ||
configuration section: | ||
|
||
```xml | ||
<plugin> | ||
<groupId>net.alchim31.maven</groupId> | ||
<artifactId>scala-maven-plugin</artifactId> | ||
<version>4.0.2</version> | ||
... | ||
<configuration> | ||
<compilerPlugins> | ||
<compilerPlugin> | ||
<groupId>org.scalameta</groupId> | ||
<artifactId>semanticdb-scalac_${scala.version}</artifactId> | ||
<version>@@SCALAMETA_VERSION@@</version> | ||
</compilerPlugin> | ||
</compilerPlugins> | ||
<args> | ||
<arg>-P:semanticdb:synthetics:on</arg> | ||
<arg>-P:semanticdb:failures:warning</arg> | ||
<arg>-P:semanticdb:sourceroot:${maven.multiModuleProjectDirectory}</arg> | ||
<arg>-Yrangepos</arg> | ||
<arg>-Xplugin-require:semanticdb</arg> | ||
</args> | ||
</configuration> | ||
... | ||
</plugin> | ||
``` | ||
|
||
Next, we need to do run bloopInstall via maven, which can be done easily | ||
through: | ||
|
||
`mvn ch.epfl.scala:maven-bloop_2.10:@@BLOOP_VERSION@@:bloopInstall -DdownloadSources=true` | ||
|
||
Everything should now be correctly configured and work even when reimporting the | ||
project. | ||
|
||
If you don't want to modify the `pom.xml` you can also run bloopInstall with an | ||
additional parameter: | ||
|
||
``` | ||
mvn ch.epfl.scala:maven-bloop_2.10:@@BLOOP_VERSION@@:bloopInstall -DdownloadSources=true -DaddScalacArgs=-Xplugin:/path/to/semanticdb-scalac.jar|-P:semanticdb:synthetics:on|-P:semanticdb:failures:warning|-P:semanticdb:sourceroot:/path/to/workspace|-Yrangepos|-Xplugin-require:semanticdb' | ||
``` | ||
|
||
`-DaddScalacArgs` takes a string with additional scalac options separated by | ||
`|`. You would need to download the correct plugin first and manually replace | ||
`/path/to/semanticdb-scalac.jar` with the path to the semanticDB plugin jar. | ||
|
||
If you choose this option though you should select "Don't show again" when | ||
Metals prompts to import the build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: mill | ||
title: Mill | ||
--- | ||
|
||
Mill is one of the newest build tools developed by Li Haoyi in order to create | ||
something simpler and more intuitive than most of other today's build tools. | ||
There is an extensive documentation on the | ||
[Mill website](http://www.lihaoyi.com/mill/). | ||
|
||
## Automatic installation | ||
|
||
The first time you open Metals in a new workspace it prompts you to import the | ||
build. Select "Import build" to start automatic installation. After it's | ||
finished you should be able edit and compile your code. | ||
|
||
## Manual installation | ||
|
||
Manual instalation is not recommended, but it's pretty easy to do. There are | ||
only two steps involved. | ||
|
||
First add one import line to your `build.sc` file or in any other file it | ||
depends on: | ||
|
||
`` import $ivy.`com.lihaoyi::mill-contrib-bloop:VERSION` `` | ||
|
||
Remember to replace the `VERSION` with your mill version. | ||
|
||
After adding the line you should be able to generate Bloop config files needed | ||
to work with Metals using the below command: | ||
|
||
`mill mill.contrib.Bloop/install` | ||
|
||
Afterwards just can just open Metals and start working on your code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters