VSCode Task to run ant buildfile located anywhere - ant

I have a huge project spread across multiple source directories which was developed the last 15 years using eclipse with custom external tools configurations to launch ant tasks from build.xml files anywhere inside the source directories (a big mess, I know!).
As the everyday work is mostly xml and JavaScript based, I thought of VSCode as a lightweight alternative (as eclipse is e.g. unable to deal with large xml files without exceeding HeepSpace). Task Runners look to me like a great way to integrate the ant builds into the editor, they are also advertised as capable of running ant builds:
Examples are Make, Ant, Gulp, Jake, Rake and MSBuild to name only a few.
I am able to run ant builds with the build.xml in the root folder. This is however not how the project is structured.
Is there a way to run the task command (ant, in my case) from a directory different to the workspace root?
I think of something like git's GIT_WORK_TREE environment variable or a way to perform two commands (like cd {{build.xml folder}} && ant). My current tasks.json is
{
"version": "0.1.0",
"command": "ant",
"isShellCommand": true,
"showOutput": "silent",
"args": ["all", "jar"],
"promlemMatcher": "" // I'm also not sure what to put here,
// but that's another question
}
(I'm on windows, btw -- but come from linux/osx and am kinda new to the ways thinks work here.)

You can either define the cwd directory to be used. This is done like this:
{
"version": "0.1.0",
"command": "ant",
"isShellCommand": true,
"options": {
"cwd": "My folder to run in"
}
}
See https://code.visualstudio.com/Docs/editor/tasks_appendix for a definition of the tasks.json file.

Related

How to execute commands needed to prepare an artifact

Is there a best practice for executing a preparation command within a CDK stack?
For example, if I was creating a Lambda and I wanted to run serverless package before deployment, is there a way to have the CDK execute that command when necessary? I was reading the documentation and it seems like maybe Construct#prepare would be appropriate?
Basically all I need to run is a child_process.execSync.
Any help appreciated!
Two approaches that I would recommend:
1. Use a wrapper script (e.g. scripts section of package.json):
{
"name": "your-app",
"scripts":{
"deploy": "serverless package && cdk deploy"
}
}
2. Use cdk.json
{
"app": "serverless package && npx ts-node bin/ci.ts"
}
Use the first if your project already uses package.json as an entrypoint for common operations. The second one is more generic but I dislike it because it's a bit more "hidden" (people who are new to CDK may never notice that it's there).

How to elegantly distribute an Erlang release?

I have created my release. The output is a fairly complicated directory structure, and many files. It has a script that I can use to execute the program ('script start', 'script console', etc.)
How do I distribute this to customers? Do I need to give them the entire directory structure? Directory bin, with the script, is not at the top level which seems to imply that perhaps only it is needed.
You have to release it in production mode. $ rebar3 as prod release tar....
This will allow them to run ./bin/appname start from the top directory. You can also choose not to include source files by configuring your rebar.config file accordingly.

Exclude directory from MSBuild Typescript compilation

I've got an ASP.NET MVC / Angular2 project which uses MSBuild to compile my Typescript files. The project contains the entire Angular2 source code and its NodeJS dependencies in addition to my Angular2 code (app.ts, etc.).
My problem is that MSBuild is compiling every Typescript file in the entire solution - including the Angular2 source code, its dependencies, and my app.ts code. I want to exclude any Typescript files located in the node_modules folder from compilation.
My understanding is that tsconfig.json files are generally responsible for excluding certain files or directories from being compiled (see this question), but that the .csproj files in ASP.NET project will supervene on tsconfig.json. So I'm trying to figure out what to write in the .csproj file to tell MSBuild and tsc.exe not to compile specific files or folders.
The MSBuild Typescript compiler options documentation is not helpful. Does anybody have any insight on this?
A .csproj file should only have your application files listed for compilation, if you have included anything from node_modules I would exclude that folder from your project. This is to prevent any weird compilation attempts by VS's TypeScript Compiler from that angle. Then, in your tsconfig.json you would have your exclude: ['node_modules', 'typings'] (if you are using #types instead of typings then obviously you won't have a typings folder). Same thing, just preventing the compiler from touching those folders.
Example tsconfig.json with the exclude in place:
{
"compileOnSave": true,
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules", "typings"
]
}
To take things a step further and hopefully save you some time when you decide to deploy your app out I think you should consider the following:
When it comes to deployment or publishing - while you could publish the entire folder and it's subfolders it is immense and time consuming. There was another, similar, question where attempting the node_module publish locked up a dev's box and eventually crashed his VS.
Trying to manually find and include all the dependencies is a) very time consuming and b) likely to drive you crazy making sure everything is included and only once. I had considered doing such a thing and rejected it.
For better or worse npm and node_modules mixed in with Windows and ASP.NET means the path of least resistance and most gain is learning an additional set of tooling to bundle up your application. The documentation is a little shakey if you're, say, dumb enough to use Webpack 2 (in beta, which I did) but the results are that you can have your npm script task, gulp task, or whatever build out only what you need for deployment. I have a 150+MB node_modules folder and I end up with a 1MB (production) set of JS files at the end of the day (tree shaking is great and I love it).
The tools for consideration are SystemJSBuilder with GulpJS (if you're already using SystemJS this is a natural path to take), Rollup (this had an issue with TypeScript interfaces and the issue I filed was listed as known and without a good fix), Webpack, and I'm sure there are more that I'm forgetting and probably even tried.
There are a number of tutorials for each available, and each has a healthy community around them. The Angular team has a webpack tutorial which is a good start if you take that route: https://angular.io/docs/ts/latest/guide/webpack.html
The SystemJS builder team has their own documentation: https://github.com/systemjs/builder but I believe you'll need to combine it with gulp documentation to learn how that pieces together.
Rollup is a bit less developed so I used their documentation http://rollupjs.org/guide/ and examples such as https://github.com/manfredsteyer/angular2-aot-webpack2-rollup
I also needed to add this line to my csproj file.
<TypeScriptCompile Remove="ClientApp\node_modules\**" />

Read DSL from file in Jenkins outside of workspace

I know its possible to run a .dsl file from an external source instead of just writing the code of the flow in the job's description, but every time I try to run lets say:
/home/flows/flow_script.dsl
I get the following error:
java.io.FileNotFoundException:/home/flows/flow_script.dsl (No such file or directory)
The path is correct, I can see the file through that path from the shell, but it doesnt let me select anything outside the "builds workspace" apparetly.
I recently ran into this very issue: my DSL script was outside of my workspace (installed via a package). The problem is that the DSL Scripts path is an Ant format that only allows specific patterns (and not absolute paths).
My workaround is hacky, but it did work: add an Execute Shell step before the "Process Job DSLs" step that symlinks the external directory into the workspace.
Something like this:
echo "Creating a symlink from /home/flows to workspace"
ln -sf "/home/flows" .flows
Then you can set the DSL Scripts path to ".flows/flow_script.dsl".
This has some additional caveats, of course: the directory you're symlinking from will need to be accessible by the jenkins user. And it likely violates a lot of best practices.

How to specify the output directory for Dart's "pub deploy"?

With Dart's "pub" tool and its "deploy" command, you can create a deployable version of your Dart web application. The output is written to the "deploy" directory. I want to know if there's a way to specify a different output directory?
I searched the internet for a command-line option, but found no mention of it. Running "pub help deploy" shows no options for the deploy command.
If "pub deploy" has no output directory option, I want to find the pub.dart source code. I'll create a customized version that accepts an output directory option. Unfortunately, I can't find pub.dart in the SDK. I found the pub shell script. It calls pub.dart.snapshot, which is 100 thousand lines of unintelligible Dart bytecode. Is there a human readable pub.dart file? Is it in the SDK?
Your help is appreciated.
For now, this is not configurable. The source folder is always /web and the output folder is always /deploy.
The source is available at http://code.google.com/p/dart/source/browse/trunk/dart/sdk/lib/_internal/pub/lib/src/command/deploy.dart#33 .
A simple workaround is just to rename deploy once generated.

Resources