Gradle copy file into generated jar (after :jar Task) - file

It it possible to copy certain files into / within the generated .jar AFTER it has been finished? E.g. I would like to simply rename one file after the compilation is done.
Ofc, one could also extract the jar, change the file and repack it again as a jar. Though I wonder whether this is optimal or not.

You can try to use shadow lib. It is plugin for Gradle.
Guide for it.

Related

Is there a way to turn a way to transform .scala file to .class file?

I have some .scala files that I want to package up into a .jar how can I turn them into .class files?
Run scalac on them. If you're using a build manager like maven or sbt, use the appropriate compile command.
I'm assuming that you have a single .scala file and that you have no library dependencies that you need to add to the class path.
scalac Foo.scala
You should look into some beginner-level language tutorials, since this is very basic. sbt is the de-facto standard build manager for scala, and I recommend reading the quick start guide there if you want to do anything more complex than what I've described above. http://www.scala-sbt.org/release/tutorial/

proper way to handle common header files with C and Git

So i have folders like this
c:\projects\generic\
c:\projects\project1\
c:\projects\project2\
Each folder under projects are their own separate local git repository. A project may use one or more header files from the generic folder. If a project uses a header file, it needs to be right in the project folder, not a subfolder under the project folder. Also, I probably wouldn't want the latest and greatest, I'd want to pull it by tag so I could be sure I have a specific version of the file in use for that project.
How would I do that? Is this something that could be done with submodules? Is there a better way to organize the folders in this situation?
I'd want [...] a specific version of the file in use for that project.
Yup: submodules are for exactly that. A submodule is a nested repository, the using projects' commits record (only) exactly which (other) commit SHA they need checked out at the submodule's path, git submodule just does the chores of getting the right submodule commits checked out when you want.
If a project uses a header file [from another repository], it needs to be right in the project folder, not a subfolder under the project folder [... I'm on windows].
It's lucky these are headers, otherwise there'd be a problem with that combination. As it is, the compiler can chase the relative pathnames with a #include "relative/path/to/submodule/header.h":
repo
|--generic.h: "#include generic1/generic.h"
|--generic1
|--generic.h: the real thing

Versioning absolute paths in qt .pro files

lets say i have a qt project file (*.pro) and related files under a versioning system (git). The project is multiplatform and developing is performed on a lot of different ones as well. Developmers are both progrmmers and not programmers (matematicians, ecc) so i'd like to keep things as easier as possible for the person who cloned it (eg: avoid env variables).
The project is dependent on other projects whose are in an non-standard folder in the developer platform.
So i need them to edit the project file INCLUDEPATH += "absolute-path-to-external-stuff"
Problem is i'd like to put this single line in a file to be included in the .gitignore (remove it from versioning once uploaded) so that one can freely edit it without editing others when pushing to repo.
Should i use .pri files (and how? it seems they only are ok in subdirectories, cant find a reference) or is there a better pattern?
You can use a .pri file for that — a .pri is just a file that gets include()d by a .pro file.
Create a file in the project root called config.pri, containing the INCLUDEPATH addition
Add include(config.pri) to your main project file
Add the config.pri to your .gitignore
In the long run, you might consider using pkg-config to manage dependencies, since it integrates nicely with qmake.

TeamCity - Copy files from commit that triggered build

I am using the "VCS Trigger" trigger: "Triggers one build per each VCS check-in".
I have two Build steps:
One that runs the .sln file
Another that copies files to the destination webroot.
Is there a way to configure TeamCity so that it only copies to the destination webroot the files that were part of the commit that triggered the build process?
I would not recommend that, since .net solutions are bundled together so that files from one build may not work in another build. At least that is my experience...

Copy changed files in Jenkins

I'm using Jenkins for building my projects. I'm using Ant to do the compilation itself.
When build finishes I'd like to copy files that were compiled in this build to some directory. Is this possible?
Yes, you could do this as part of your Ant project using the Ant copy task. Best practice is to clean the directory containing your compiled binaries at the start of each build, so you should just be able to copy the whole directory without filtering the contents.
If you want to specifically find changed files, you could take a recursive md5 over your Target directory before and after your build, and only copy those files which do not match the prebuild checksum.
This being said, if you've got a clean build directory you should just copy everything over; changed files will get copied as needed, and unchanged files will copy but won't impact the application.

Resources