Configure Sublime Text build system for Scala? - scala

I'm trying to configure a build system for Scala with SublimeText, but I am having some difficulty. I have tried both of the following:
{
"shell_cmd": "scala",
"working_dir": "${project_path:${folder}}",
"selector": "source.scala"
}
{
"cmd": ["/path/to/bin/scala", "$file_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala",
"shell": true
}
Both of these attempts produce the same failed output - it seems to start up the interactive Scala shell rather than running my script. Any advice?

The answer that worked turned out to be very close to the second answer - apparently I'm not supposed to open up a new shell. If someone can clarify when to set "shell": true in the comments, that would be really helpful.
{
"cmd": ["/path/to/bin/scala", "$file_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala"
}

{
"cmd": ["C:/Program Files (x86)/scala/bin/scala.bat", "$file_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala"
}
This worked for me.
replace C:/ with your own path.

In Packages/Scala/Scala.sublime-build, add this:
{
"cmd": ["[PATH TO SCALA]", "$file"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala"
}
Replace the [PATH TO SCALA] with the path of where scala interpreter is located in your system. Do a "which scala" to find out.

This works for me:
{
"cmd": ["scala", "$file"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala",
"shell": true
}
given you set the system PATH thing:
Variable: %PATH%
Value: C:\Program Files (x86)\scala\bin

in my case I didn't install Scala or SublimeText, I just used the zip. But this code worked for me to compile the .scala files from SublimeText3 on Windows.
{"cmd": ["C:/Scala/scala-2.13.3/bin/scalac.bat", "$file"],
"working_dir": "$file_path",
"selector": "source.scala",
"encoding":"utf-8",
"file_patterns": "*.scala",
"shell": true}
You can create it or download it and put it in the directory Sublime Text Build 3 ###\Data\Packages\User

Build System For Scala :
OSX - (Mac)
Use the below:
{
"cmd": ["/opt/homebrew/bin/scala", "$file_name"],
"working_dir": "${project_path:${folder}}",
"selector": "source.scala"
}
Path to delete the build:
/Library/Application Support/Sublime Text/Packages/User

Related

CI Using Azure Pipelines and Nx fails

UPDATE: I was able to get this working by setting "ProduceReferenceAssembly" to false in the .csproj files of the libs. Not sure if this is optimal or intended but that is what worked for me. See: Ref folder within .NET 5.0 bin folder
I'm trying to set up a proof of concept using NX dot net and Azure using this exaple .yml: https://nx.dev/recipes/ci/monorepo-ci-azure
I have 3 services (libs) and 3 apis (apps) ... I made a change to one of the apis to test caching and incremental builds.
The unchanged projects all say [remote cache] but then the build fails because it's looking for the .dlls in the /obj/Debug/ directory. Why use that when there are .dlls in the /dist directory?
How can I fix this? Is there something in the nx.json or project.json files I need to change?
(https://i.stack.imgur.com/IQhaO.png)
I tried using the same command locally on my machine and it completes as expected. I expect the build to complete. The build fails when remote caching is used.
{
"name": "ShipmentService",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"sourceRoot": "libs/ShipmentService",
"targets": {
"build": {
"executor": "#nx-dotnet/core:build",
"outputs": [
"{workspaceRoot}/dist/libs/ShipmentService",
"{workspaceRoot}/libs/ShipmentService/obj"
],
"options": {
"configuration": "Debug",
"noDependencies": true
},
"configurations": {
"production": {
"configuration": "Release"
}
}
},
"lint": {
"executor": "#nx-dotnet/core:format"
}
},
"tags": []
}
Tried proposed workaround, here's what I'm noticing: platformservice:build [remote cache]
Error, it sees the intermediates part, but basically same issue: same error
Updated project.json (all of them have been updated to look similar to this [tried with and without /obj portion]):
"outputs": [
"{workspaceRoot}/dist/libs/ShipmentService",
"{workspaceRoot}/dist/intermediates/libs/ShipmentService/obj"
],
This is a bug on nx-dotnet's side, and we aren't quite capturing all of the outputs that are needed for the cache. If you add the path to the obj directory into the outputs array of the build target in project.json it should work. Here's the workaround which will eventually be migrated:
I've got a branch with this working, you do indeed need the obj directory as part of the cache. There are some weird intricacies with this though. I'll work on a migration + patch. In the meantime, the workaround that I used is:
Update Directory.Build.props adding these to the property group containing the output path manipulation:
<BaseIntermediateOutputPath>$(RepoRoot)dist/intermediates/$(ProjectRelativePath)/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
As an example, the full file looks like this on the nx-dotnet repo now:
<Project>
<PropertyGroup>
<!-- Output path configuration -->
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<ProjectRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</ProjectRelativePath>
<BaseOutputPath>$(RepoRoot)dist/$(ProjectRelativePath)</BaseOutputPath>
<OutputPath>$(BaseOutputPath)</OutputPath>
<BaseIntermediateOutputPath>$(RepoRoot)dist/intermediates/$(ProjectRelativePath)/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
<PropertyGroup>
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
</PropertyGroup>
</Project>
Your project.json file should look something like this now:
{
"name": "demo-webapi",
"sourceRoot": "demo/apps/webapi",
"targets": {
"build": {
"executor": "#nx-dotnet/core:build",
"outputs": [
"{workspaceRoot}/dist/demo/apps/webapi",
"{workspaceRoot}/dist/intermediates/demo/apps/webapi"
],
"options": {
"configuration": "Debug",
"noDependencies": true
},
"configurations": {
"production": {
"configuration": "Release"
}
}
}
}
}

How to fix: "The asset path must start with the project source root"?

We have an nrwl/nx project, that we can build on Windows, but it fails on Linux (Ci sytem).
The error is:
The /root/dev/apps/dmc-svr/src/assets asset path must start with the project source root: apps\dmc-svr\src
It seems to be a Windows/Linux path issue
The problem was a Windows like path for the sourceRoot property in project.json
{
"sourceRoot": "apps\\dmc-svr\\src",
"targets": {
"build": {
"executor": "#nrwl/node:build",
"options": {
"assets": [
"apps/dmc-svr/src/assets",
]
}
}
}
}
the fix is to simply replace the backslash \\ with a slash \: sourceRoot": "apps/dmc-svr/src"
We guess that this has been generated by some nx-schema.

How to run jsdoc on directory ignore .gitignore files

I can run jsdoc on a whole project with
$ jsdoc -r .
However this generates docs for js files inside node_modules. How can I tell jsdoc not run on files in .gitignore?
How about using a config file such as this one?
$ jsdoc.js -c ./.jsdoc.conf.json
./.jsdoc.conf.json
{
"source": {
"include": ["."],
"includePattern": ".+\\.js(doc|x)?$",
"excludePattern": "node_modules"
}
}
Borrowed from Generate jsdoc documentation here on Stack.
{
"source": {
"include": ["."],
"includePattern": ".(jsx|js|ts|tsx)$",
"exclude": [
"node_modules",
"docs"
]
}
}

how to pass multiple args to vscode task command?

in tasks.json I am using the "args" property to specify the arguments to pass to "command":"gulp". But when I run the task in vscode, only the first argument is being passed to gulp.
I want to run a gulp task against a single file. In gulpfile.js I am using the process.argv array to retrieve the command line arguments. So, on the command line I enter "gulp copy3 --file abc.js" and the copy3 task is run. The code then reads the argv array to get the name of the file being copied.
this code works from the command line. But does not work when I run it as a task in vscode. How to do that?
the gulpfile.js code:
gulp.task('copy3', function( )
{
console.log(process.argv) ;
let pattern = '*.js' ;
// single file to copy
if (( process.argv.length >= 5 ) && ( process.argv[3] == '--file' ))
{
let fileName = process.argv[4] ;
pattern = fileName ;
}
console.log('pattern:' + pattern ) ;
return gulp.src(pattern).pipe(gulp.dest('dev'));
}) ;
the tasks.json file
{
"version": "2.0.0",
"tasks": [
{
"taskName": "copy3",
"command": "gulp",
"args": [ "copy3", "--file", "${fileBasename}" ],
"problemMatcher": []
}
]
}
Here is the terminal output:
[10:52:57] Using gulpfile C:\vscTest\rpgproj\gulpfile.js
[10:52:57] Starting 'copy3'...
[ 'C:\\Program Files\\nodejs\\node.exe',
'C:\\vscTest\\rpgproj\\node_modules\\gulp\\bin\\gulp.js',
'copy3' ]
pattern:*.js
[10:52:57] Finished 'copy3' after 16 ms
thanks,
I made a couple of small changes, try:
{
"label": "Tasks: copy3",
"type": "shell",
"command": "gulp",
"args": [ "copy3", "--file", "${fileBasename}" ],
"problemMatcher": []
}
and your entire code works perfectly. Make sure to reload vscode after modifying the tasks.json.
VSCode appears to have a built-in gulp extension. This seems to scan your gulpfile for tasks and list them for you. It also seems to ignore the args option.
The workaround is to use the full path to gulp as the command e.g. ./node_modules/.bin/gulp to bypass it.

Error running CoffeeScript in Sublime Text 2

I am new to both CoffeeScript and Sublime Text 2, so any help would be greatly appreciated.
When I try to compile a CoffeeScript test file in Sublime, I get the following error message:
[Error 2] The system cannot find the file specified
[cmd: [u'coffee', u'-c', u'C:\\Users\\username\\Desktop\\test.coffee']]
[dir: C:\Users\username\Desktop]
[path: $HOME/bin:/usr/local/bin:$HOME/bin:/usr/local/bin:C:\Program Files (x86)\ImageMagick-6.9.1-Q16;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Java\bin;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\nodejs\;C:\Program Files (x86)\GnuWin32\bin;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\Skype\Phone\;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.1.0\bin;C:\Users\username\AppData\Roaming\npm]
[Finished]
Here are my build settings in commands:
{
"path": "$HOME/bin:/usr/local/bin:$PATH",
"cmd": ["coffee","-c","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee, source.litcoffee, source.coffee.md"
}
Any idea how to fix this problem? Thanks.
I managed to get it working with the following code in the build file:
{
"cmd": [ "coffee", "-m", "-c", "$file" ],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.coffee, source.litcoffee, source.coffee.md",
"windows":
{
"shell": true
}
}