Sbt can re-run tasks when some of watched files have changed (~task). How to find out which files have changed?
You can add this to your build.sbt to see what files are watched:
watchSources ~= { files =>
println(files.mkString("\n")+"\n\n\n")
files//here you can add files or filter out
}
It might help you to test specific Test classes: ins sbt (interactice mode):
~test-only full.path.test.ClassName
To track file changes in general you can use Java 7 WatchService or Apache VFS for Java 6.
Source: WatchService for Java 6
Related
I want to apply this deno.json configuration file to all my deno projects:
{
"fmt": {
"options": {
"indentWidth": 4
}
}
}
Is there a way to globally apply this configuration so I don't have to have this deno.json file in every project?
I'm using VSCode, Ubuntu and Deno 1.28.1.
Because of the way that the Deno VS Code extension overrides/suppresses the built-in TS language server, it is not advised to enable the extension globally: this would cause problems in every non-Deno TypeScript project.
That said, you can create a single deno.json(c) file at a high-level location in your filesystem — for example: in your home directory. To use a concrete example location — on Linux — /home/your_username/deno.json.
Then, when configuring a new VS Code project, you only need to configure the location of the config file in .vscode/settings.json in order for the extension to use it:
{
"deno.enable": true,
"deno.config": "/home/your_username/deno.json"
}
When using Deno in the CLI, it will automatically walk your filesystem and find the nearest parent config file. From the manual:
Since v1.18,
Deno will automatically detect deno.json or deno.jsonc configuration file if
it's in your current working directory (or parent directories).
Regardless of the above, this strategy is not advised: a better approach might be to simply to create a personal CLI script/function which will generate a new deno config and VS Code config from a template that you create. This way, each of your projects maintains its own configuration data (a good thing) and you also don't have to manually configure each new one because you did the work once to create the template generation script (win-win).
I'm working on an SBT project that has to be built with the options like:
-Xmx2G -Xss256M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled
This means that every new developer has to read the readme and assign the options to SBT_OPTS in bash profile or put them in the sbtopts file. Similarly, this has to be configured on Jenkins and this applies to all the projects (so if someone wants to use -XX:+UseG1GC with other projects it becomes an issue). Is it possible to specify the required options in the build file itself? This seems logical to me, as the options are project-specific and without them, you cannot build the project.
Create a .sbtopts file at the root of the build with contents:
-J-Xmx2G
-J-Xss256M
-J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled
I use sbt 0.13.5 to build a project with a few config files meant to be human-edited after deployment.
Using sbt-native-packager's stage command builds my basic output directory structure for deployment. This results in a bin folder with a start script and all my jars in a lib folder. Great.
That just leaves the text config files that should be copied into a conf folder verbatim alonside the bin/ and lib/ folders (not included in any jar).
How can I copy these configuration files to the output directory on the filesystem (not into any jars) using sbt?
I'm unsure about an out-of-the-box support for src/main/conf directory or similar, and unless you find it, use the following as a workaround:
packageArchetype.java_application
mappings in Universal ++= {
((sourceDirectory in Compile).value / "conf" * "*").get.map { f =>
f -> s"conf/${f.name}"
}
}
It maps files under src/main/conf to conf directory in the package.
NB: I'm pretty sure I've seen somewhere in the code support for the conf directory.
Default Universal convention is to copy files/directories under src/univeral/. So, to include a conf/ directory in the distribution, just add src/universal/conf and copy configuration files there. Credit: this link
This seems to be a 'better' answer, as I am using sbt together with sbt-native-packager plugin:
mappings in Universal ++= contentOf( baseDirectory.value / "conf" )
This takes all the files under the specified "conf" folder and dumps them in the package root folder.
Which uses the MappingsHelper I stumbled upon in the very terse documentation for it in the sbt-native-packager.
Is there a way to run a task on every code change in a given directory? Preferably, something that works well with ~ operator in SBT so that I could do:
~jadeCompile
to run custom jadeCompile task.
Take a look at the documentation for triggered execution. You can configure the watched directory using the watchSources setting. This is a bit trickier as only Scala source files will be watched by default, so we need to specify an appropriate path finder:
watchSources <++= baseDirectory map { path =>
((path / "src/main/jade") ** "*.jade").get }
The watchSources setting is not scoped, so you will need to watch all sources at once. Then you just have to run:
~jadeCompile
i want to have a directory that is not deployed to the server, nor is it packaged to be sent to the clients.
I read the 'tests' dir behaves this way, but i don't want to store all my files that don't nee deployment in the tests dir. tests is just for tests...
I want to include my sass files (.scss) in my project, but only the compiled css needs to be deployed (I compile to client/style.css). All of the sass source files and compass configuration files don't need to be deployed anywhere.
How to do this?
I hope I don't need to stor everything in the tests dir...
Thanks!
Pieter
As stated in this other SO, directories whose name start with a dot (Unix hidden directories) aren't included by meteor. I use it for my less partials: client/css/.partials/_<partial_name>.less.
You could modify Meteor's app/lib/bundler.js, line 37 to include your extension:
var ignore_files = [
/~$/, /^\.#/, /^#.*#$/,
/^\.DS_Store$/, /^ehthumbs\.db$/, /^Icon.$/, /^Thumbs\.db$/,
/^\.meteor$/, /* avoids scanning N^2 files when bundling all packages */
/^\.git$/, /* often has too many files to watch */
/*.scss$/
];
or you could make package.js for your sass files, using stylus as an example.