Custom build steps in Intellij IDEA project - build

I have an external tool I need to be executed everytime Intellij runs Make. In eclipse I could easily modify the build steps, but I dunno how to achieve that here.
Any ideas?
I expect that it would deal with my resources using external script without having to run it manually before each test run.

It's possible via Ant or Maven right now.
For example you can add build.xml to the Ant Build panel in IntelliJ IDEA, create Ant target that will run your command line tool with the <exec> task, right click on this target and set it to run automatically (Execute on | Before Compilation or After Compilation).

Related

How do I automatically make after cmake finished generating the files

I am currently trying to set up an "automatic build process" on mac for my C++ "Hello World Project" that uses Cmake & visual studio code.
My current workflow to build in terminal or with vscode's tasks.json is the following, and I find them very tedious to do.
cmake ... (to generate the cmake & make files inside the build folder)
make (inside the build folder to create the application's executable)
./{application's executable}
Thus, I have have looked into the following
vs code's prelaunch task
cmake's add_custom_commands
custom bash script
python scripts
But I'm a bit lost with the above try-outs, and need some helps. My end goal is to automatically build and run the updated code by either pressing F5 in vscode or calling a custom ./{command} in terminal.
Combining everyone's suggestions, the approach I took is to create a task.json that contains the following command-flow
cmd1: cmake to generate the makefiles & cmake files to a build folder
cmd2: make -j 8 to build with multiple cores
cmd1 && cmd2
Then I made two different launches in launch.json. The major difference between them is the prelauch task. One of them is "cmd1&&cmd2", and another one is only "cmd2". That way I can have two hotkeys like F5 and F7 for me to choose. If the folder structure & files weren't added or removed I will hit F7 which only calls the "cmd2" pre-launch task, otherwise F5.
I think a better approach is to either write a bash script or dig deeper in cmakelist.txt which I believe it has the "if statements" that determine when should it do "cmd1 &&cmd2" or just "cmd2" alone. That way, I don't need two hotkeys to build/debug and run in vscode (don't know if it is possible, I haven't try yet.)
If anyone has done it, please comment below or create a new answer.
Thank you all!
You can run
cmake --build
after the first time you configured the build. Optional parameters include the build directory and targets to build.

Eclipse: add a run configuration in a makefile project

I have an Eclipse project that builds a library, with my own build script (that basically sets some variables, then calls a Makefile). I have set the Build Configuration to run this script, everything is OK: I can compile by just clicking on the Build button.
Now, I would like to test some parts of this lib. In the same project, I have created a C++ source file, with a little main(). I would like to create a run configuration to execute this small test program, but Eclipse tells me that "the binary does not exist" (of course, since I want to build it...).
What is the solution ?

TeamCity with msunit: How to copy dll into output folder?

I want to run my (working) msunit tests with teamcity. Within my test, I need several files which I successfully copied using either one of the following ways (when running the tests from within VS):
file properties -> copy to output directory
or copying them using a post build step using xcopy
As post build actions I tried:
xcopy /Y "$(ProjectDir)*somelib*.dll" "$(TargetDir)"
or
xcopy /Y "$(ProjectDir)*somelib*.dll" "$(OutDir)"
As you can see, I have somelib.dll files that need to be copied. This is due to the usage of a library, which I listed as a reference. This lib is copied corretly, but it needs some older (c++) dlls, which are not included in the reference package.
Unfortunately I could not find a way to either get TeamCity to run the msunit test within the bin/debug/ folder, or to copy all neccessary files to the working temp folder.
(My goal is to run all unit tests from several test suites and to gather results from dotCover for all tests.)
What is a good way to deal with this situation? I noticed the possibility to pack files into the assembly as resources, and to unpack them inside the unit tests right before they are needed. I will need the dlls in every test and would like to keet it DRY - is this a wise way to "just" copy the files?
As far as TeamCity is concerned, you can make sure the process works when run from the command line (n the TeamCity agent machine, in the same directory, etc.) and then replicate the same steps in a TeamCity build. Since TeamCity just launches MSBuild as external process and executes the configured commands, there should be no TeamCity-specific peculiarities.

Export projects as .jar in IntelliJ

I've recently switched from Eclipse to IntelliJ, and i'm a bit confused as to how to export projects as .jars. I've seen other posts, where the answer is to go to File > Project Structure > Artifacts, and add a new build artifact, and then use Build > Build Artifacts. However, I don't know where the jar is being saved, (if it is) and I would also like to know how to make it export to a custom location. I also think it's kind of strange how it takes IntelliJ around 20 or so seconds to compile the jar, while in Eclipse it only takes half a second.
You can also use "Build on make" option. IntelliJ will make new jar for you on each "make" invocation. Assuming there were changes. Otherwise it will keep the existing jar.
Also, "Artifacts" configuration screen contains the location of the artifact.

TFS not clearing build agent folders after migration to TFS2010

I am having an issue with TFS. When we had TFS2008, the build machine was able to clear files from the Build Agent Folders before creating a new build. However, after the migration to TFS2010, the build machine cannot clear this folder and we are getting builds with old files that have been deleted from source control.
Is there any way to get this functionality back? We are currently working with the TFS2008 build scripts and the UpgradeTemplate.xaml in TFS2010.
Thanks
In your TFS Build Definition, what is the "Clean Workspace" on the "Process" tab set to?
It has three options:
All
Outputs
None
An explanation of each options (taken from TFS):
Set to All to delete all existing outputs and sources and do a full
rebuild; Outputs to delete all existing outputs but get only those
source files that have changed since the last build (Incremental Get);
or None to leave existing outputs and sources in place and build any
changes incrementally.
You should set this to All, to ensure you are performing a clean build each time.
The only other post I found didn't have an answer. So instead, I reverted back to running a RMDIR command at the BeforeEndToEndIteration level of the build script.
<Target Name="BeforeEndToEndIteration">
<Exec WorkingDirectory="S:\src" Command="RMDIR /s /q "S:\src\Sandbox_awdbu\""/>
</Target>
This command will delete the build agent folder before the Get Latest command is performed by the build service.
It's not a great solution but it works. This solution will work but I would suggest moving onto the template instead of keeping the old TFS2008 build scripts.