Run CMD/Powershell command before the build command? - intellij-idea

How I can run a CMD/Powershell before my Java GUI Application will be build and invoked.
I want run the command: sass ANYFILE.scss:ANYFILE.css to compile my scss file first.
In the Run/Debug Configurations I found nothing which helps me at the Before launch option.

Add the External Tool in IDE which will run any command you want, then add it in Before launch section.
There is a PowerShell plugin that provides a run configuration to run powershell scripts. You can add it as Before launch option as well.

Related

Schedule run configurations automatically

I have a Intellij Gradle Run configuration. Is there a way to schedule this to run automatically? The commandline that IntelliJ use to run this seems to be hidden so I couldn't simply make a cron job for this with command line.
There is no such feature in IntelliJ. If it's a Gradle configuration, the only IntelliJ-specific command line customizations are related to running inside the IDE, so you can simply create a cron job that would run 'gradlew name-of-your-task>'.

Use custom script in Intelij IDEA to run sbt shell

Is it possible to run sbt shell in Intelij IDEA using custom script instead of built in sbt or sbt from sbt-launch.jar? Why I need this, for example there is some project which uses custom script to set config file location, VM parameters, and other options for sbt and this script is shared in version control system. And it would be very convenient to just specify for IntelliJ IDEA location of such script.
This is currently not possible. However, to pass project-specific sbt command line parameters to sbt you may place a .sbtopts in your project directory, and likewise a .jvmopts for VM parameters.

How do I run a EXE Go executable from within IntelliJ IDEA?

I have a Go program which I'm working on in IntelliJ IDEA on a Windows machine. The program's structure is a little unconventional (don't want to go into detail here as its besides the point) because of which I first have to compile the program using the following command:
go build -o cli.exe
And then I can run cli.exe directly in the command prompt.
But how do I configure the run configuration in IntelliJ IDEA so that it doesn't mind running a Windows executable ? Because if I try to tell it to run an EXE file as it's run configuration, it gives me error "Main file is invalid"
How do I solve this ?
Make sure you have a file name (not a folder name) in field File on Run/Debug Configuration window (In IntelliJ IDEA go to menu Run->Edit Configuration...->your_configuration). That was my case.
You may be able to install the Bash plugin on Windows, then create a run configuration using the Bash plugin, and just run your executable from a script.
Create a Go Application run configuration and that should work. You can choose to run either a file or a package. If you would share more details then the answer would be more complete. If you still have an issue with this, please open an issue to the bug tracker and I'll be able to help out (please follow the issue template there).

PhantomJS teamcity config

In a teamcity config I have build step which runs PhantomJS tests. It is a "Command Line" step with custom script. The script looks like:
%PhantomJS% CreateEntityPopupTest\unit.htm
%PhantomJS% ExcelImportPopupTest\unit.htm
...
etc.
So it runs each qunit test package mentioned in the htm page. But I didn't manage to find a way to point PhantomJS (phantomjs-1.9.0-windows) to a folder, not to a single file. So there would be no need to change the config each time when we add new files with tests.
I used Chutzpah to wrap this behavior for use in TeamCity. Chutzpah can run tests written in QUnit, Jasmine or Mocha and uses PhantomJS as the headless test runner.
https://github.com/mmanela/chutzpah
I installed it on the build agents and added it to the path on the machine.
Now I simply add a Command line runner step called 'Run JS Test' in my build template. Command line is simply:
chutzpah.console.exe %jsTestFolder%
Then I just define the parameter for each project pointing to a folder... chutzpah does the rest.

IntelliJ IDEA: Running a shell script as a Run/Debug Configuration

Is there a way by which a shell script can be invoked from IntelliJ Run/Debug configurations?
I just found out that we can invoke a shell script with the help of BashSupport plugin.
'Add External tool' in the 'Before Launch' does the trick.
Screenshot
IntelliJ IDEA 2019.2 update
New version of IntelliJ IDEA has Shell Script Support included. It means you can now create Shell Script build for your project.
Edit Configurations > (+) Add New Configuration > Shell Script
You can also build your project before executing your script by adding Run Another Configuration task. That's how it looks like: Add Shell Build window
Not sure about 11, but in 12 there's a part of Run/Debug Configuration that is called "Before Launch" and you can select your shell script in "Add External tool" option.