-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
seemingly functional ide +configs sane readme +bsd3c drop spurious artifacts bump bump +ammonite support + cleanups and docs and better examples
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
tools/idea-IC-202.7660.26 | ||
tools/intellij-bazel |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build -s --sandbox_debug --verbose_failures | ||
run -s --sandbox_debug --verbose_failures | ||
build --strategy=Scalac=worker | ||
build --worker_sandboxing |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.3.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
tools/intellij-bazel | ||
idea-IC-202.7660.26 | ||
ideaIC-2020.2.3.tar.gz | ||
3rdparty | ||
bazel-* | ||
tools/bazelisk* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "intellij-bazel"] | ||
path = tools/intellij-bazel | ||
url = https://github.com/bazelbuild/intellij.git |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
directories: | ||
# Add the directories you want added as source here | ||
# By default, we've added your entire workspace ('.') | ||
. | ||
|
||
# Automatically includes all relevant targets under the 'directories' above | ||
derive_targets_from_directories: true | ||
|
||
targets: | ||
# If source code isn't resolving, add additional targets that compile it here | ||
//src:main-bin | ||
//src:main-docker | ||
|
||
additional_languages: | ||
# Uncomment any additional languages you want supported | ||
# android | ||
# dart | ||
# kotlin | ||
# python | ||
scala |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.system.id="Blaze" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$/../.."> | ||
<excludeFolder url="file://$MODULE_DIR$/.." /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../.idea" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module external.system.id="Blaze" type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$/../../.."> | ||
<sourceFolder url="file://$MODULE_DIR$/../../.." isTestSource="false" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../.." /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../bazel-bin" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../bazel-genfiles" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../bazel-out" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../bazel-testlogs" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../bazel-urep-scala" /> | ||
<excludeFolder url="file://$APPLICATION_HOME_DIR$" /> | ||
<excludeFolder url="file://$MODULE_DIR$/../../../tools/intellij-bazel" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="library" name="scala-library-2.12.8_1798c1ef" level="project" /> | ||
<orderEntry type="library" name="scala-reflect-2.12.8_4e6073f1" level="project" /> | ||
</component> | ||
</module> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<configuration name="Bazel build src:main-bin" type="BlazeCommandRunConfigurationType" factoryName="Bazel Command" nameIsGenerated="true"><blaze-settings kind="scala_binary" handler-id="BlazeJavaRunConfigurationHandlerProvider" blaze-command="build"><blaze-target>//src:main-bin</blaze-target></blaze-settings><method v="2"><option name="Blaze.BeforeRunTask" enabled="true" /></method></configuration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<configuration name="Bazel run src:main-bin" type="BlazeCommandRunConfigurationType" factoryName="Bazel Command"><blaze-settings handler-id="BlazeJavaRunConfigurationHandlerProvider" blaze-command="run" kind="scala_binary"><blaze-target>//src:main-bin</blaze-target></blaze-settings><method v="2"><option name="Blaze.BeforeRunTask" enabled="true" /></method></configuration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
align.openParenCallSite = false | ||
align.openParenDefnSite = false | ||
continuationIndent.defnSite = 2 | ||
docstrings = JavaDoc | ||
importSelectors = singleLine | ||
maxColumn = 120 | ||
rewrite.redundantBraces.stringInterpolation = true | ||
rewrite.rules = [ | ||
RedundantParens, | ||
PreferCurlyFors, | ||
SortImports | ||
] | ||
unindentTopLevelOperators = false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package( | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
scala_binary( | ||
name = "amm", | ||
srcs = [], | ||
deps = ["@third_party//3rdparty/jvm/com/lihaoyi:ammonite_2_12_8", "//src:mylib"], | ||
main_class = "ammonite.Main" | ||
) | ||
|
||
|
||
# this is the base docker image used for all scala_image targets | ||
# adoptopenjdk is great, but their images do not have the `java` executable at the path expected by rules_docker | ||
|
||
container_image( | ||
name = "custom_java_base", | ||
base = "@openjdk-base//image", | ||
symlinks = {"/usr/bin/java": "/opt/java/openjdk/bin/java"}, | ||
visibility = ["//visibility:public"], | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2020, itdaniher | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
## Bazel infrastructure for Scala | ||
|
||
|
||
### What's included? | ||
|
||
- functioning, up-to-date, intellij support! | ||
- [bazel-deps](https://github.com/johnynek/bazel-deps) for managing dependencies via dependencies.yaml. | ||
- [rules_scala](https://github.com/bazelbuild/rules_scala) for compiling and formatting, via scalafmt | ||
- [rules_docker](https://github.com/bazelbuild/rules_docker) for packaging and isolated deployment | ||
- [ammonite](http://ammonite.io/) as a powerful REPL for working with your libraries | ||
|
||
bonus compatible versioning for... | ||
|
||
akka, scalaz, circe, logstage | ||
|
||
#### getting started on the CLI | ||
|
||
Ubuntu 20.04, amd64 - confirmed to work. Everything else may require some tweaks. | ||
|
||
* clone this repo | ||
* `git submodule init && git submodule update` - to grab the intellij bazel plugin for IDE support | ||
* `./scripts/update_bazel_deps.sh` - grab dependencies | ||
* download [bazelisk](https://github.com/bazelbuild/bazelisk) from [here](https://github.com/bazelbuild/bazelisk/releases/download/v1.7.4/bazelisk-linux-amd64) | ||
* rename as `bazel` and mark executable, place somewhere in your $PATH | ||
* hello, world! | ||
|
||
#### hello world, and hello world in docker | ||
|
||
``` | ||
SPX:~/urep-scala $ bazel run //src:main-bin | ||
INFO: Analyzed target //src:main-bin (0 packages loaded, 0 targets configured). | ||
INFO: Found 1 target... | ||
Target //src:main-bin up-to-date: | ||
bazel-bin/src/main-bin.jar | ||
INFO: Elapsed time: 0.195s, Critical Path: 0.01s | ||
INFO: 0 processes. | ||
INFO: Build completed successfully, 1 total action | ||
INFO: Build completed successfully, 1 total action | ||
Hello world! | ||
I am running on 11.0.9+11-Ubuntu-0ubuntu1.20.04 | ||
this is a string in a library. | ||
SPX:~/urep-scala $ bazel run //src:main-docker | ||
INFO: Analyzed target //src:main-docker (47 packages loaded, 6463 targets configured). | ||
INFO: Found 1 target... | ||
Target //src:main-docker up-to-date: | ||
bazel-bin/src/main-docker-layer.tar | ||
INFO: Elapsed time: 2.457s, Critical Path: 0.68s | ||
INFO: 0 processes. | ||
INFO: Build completed successfully, 1 total action | ||
INFO: Build completed successfully, 1 total action | ||
Loaded image ID: sha256:ad196f426e5adf796470e6d861526f7de92ab2821e67087cb6a7eda671ad4146 | ||
Tagging ad196f426e5adf796470e6d861526f7de92ab2821e67087cb6a7eda671ad4146 as bazel/src:main-docker | ||
Hello world! | ||
I am running on 11.0.8+10 | ||
this is a string in a library. | ||
``` | ||
|
||
#### hello world, with Ammonite | ||
|
||
`bazel run //:amm` | ||
|
||
|
||
``` | ||
SPX:~/urep-scala $ bazel run //:amm | ||
INFO: Analyzed target //:amm (1 packages loaded, 4 targets configured). | ||
INFO: Found 1 target... | ||
Target //:amm up-to-date: | ||
bazel-bin/amm.jar | ||
INFO: Elapsed time: 0.092s, Critical Path: 0.00s | ||
INFO: 0 processes. | ||
INFO: Build completed successfully, 1 total action | ||
INFO: Build completed successfully, 1 total action | ||
Loading... | ||
Welcome to the Ammonite Repl 2.2.0 (Scala 2.12.8 Java 11.0.9) | ||
@ import com.urepscala.mylib._ | ||
import com.urepscala.mylib._ | ||
@ println(com.urepscala.mylib.MyLib.myString) | ||
this is a string in a library. | ||
@ com.urepscala.mylib.MyLib.helloWorld | ||
hello, world! | ||
@ Bye! | ||
``` | ||
|
||
#### format your code with scalafmt and bazel! | ||
|
||
``` | ||
SPX:~/urep-scala $ bazel run //src:main-bin.format | ||
INFO: Analyzed target //src:main-bin.format (0 packages loaded, 0 targets configured). | ||
INFO: Found 1 target... | ||
SUBCOMMAND: # //src:main-bin [action 'ScalaFmt src/src/main/Main.scala.fmt.output', configuration: 45d0b89373a0dfd75ac4b432cf2b12138c1203b34bdec57557dfef52e7a6ed03] | ||
(cd /home/name/.cache/bazel/_bazel_name/0f392d4f227f7735cc2ffb1555d4a4e9/execroot/__main__ && \ | ||
exec env - \ | ||
bazel-out/host/bin/external/io_bazel_rules_scala/scala/scalafmt/scalafmt '--jvm_flag=-Dfile.encoding=UTF-8' @bazel-out/k8-fastbuild/bin/src/src/main/Main.scala.fmt.output-0.params) | ||
Target //src:main-bin.format up-to-date: | ||
bazel-bin/src/main-bin.format | ||
INFO: Elapsed time: 0.192s, Critical Path: 0.06s | ||
INFO: 1 process: 1 worker. | ||
INFO: Build completed successfully, 2 total actions | ||
INFO: Build completed successfully, 2 total actions | ||
``` | ||
|
||
#### build plugin for intellij: | ||
|
||
The checksum for a dependency in the intellij plugin is presently incorrect, for whatever slightly unsettling reason. | ||
|
||
Patch in the expected checksum and build the intellij plugin zip by running the below as "build.sh" in `tools/intellij-bazel/` | ||
|
||
```bash | ||
|
||
#!/bin/bash | ||
|
||
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 | ||
|
||
git checkout 1b66ac89e13513243f910c9cf950d99872ce8d5b | ||
|
||
sed -ie 's/fa9524db2f5b6e42be559ffdab73a963ca06ca057e27a290f5665d38e581764a/61eb876781f3fd75f2d9e76cac192672a02e008725ad9d7ac0fbd4e3dcf25b16/' WORKSPACE | ||
|
||
bazel build //ijwb:ijwb_bazel_zip --define=ij_product=intellij-2020.2 --sandbox_debug --verbose_failures | ||
|
||
cp bazel-bin/ijwb/ijwb_bazel.zip . | ||
|
||
echo 4b4d9d6e52aa559e79f7b0a9fbfcdbcece3e91a8add7d7c0eed51b3cad8dde23 ijwb_bazel.zip | sha256sum -c - | ||
|
||
echo 'WORKSPACE' >> .gitignore | ||
``` | ||
|
||
TODO: add this as a bazel rule :) | ||
|
||
#### the rest of the owl | ||
|
||
* grab intellij community edition: | ||
|
||
`wget https://download.jetbrains.com/idea/ideaIC-2020.2.3.tar.gz` | ||
|
||
install the plugin (built?) and settings (from releases), cross your fingers | ||
|
||
TODO: add these steps as a bazel rule :) |