Copying resource file into directory before compile
I need to change resource files for different scenarios.
Please don't ask me why, the explanation is quite lengthy if you want to understand it.
The short explanation is legacy code and a really old library that is required in my domain.
I need the files to be present, before any code generation or compilation is performed. These resources are referenced by some Library that performs checks and code generation during compile time.
I can not dump the library and write a better one from scratch, since the old one needed to undergo a pretty expensive certification which I am not really comfortable to disclose here.
Do you know an existing maven plugin, that can perform a cop operation besides maybe
antrun
?
If there is not, I will write my own plugin and maintain it.
It would be cheaper to do that, than to get certification for a new library.
This is an example of what my directory structure might look like.
The one in the resources directory is supposed to be the destination.
I want to do this inside of maven, so I could avoid writing special scripts and needing an explanation for every new developer how to set up the run configs in intellij correctly.
If I would do that, someone would have to maintain it with changing versions of Intellij in the future and we all know that this will not happen.13 Replies
⌛
This post has been reserved for your question.
Hey @NeoCortex97! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Please tell me if this is not in the scope of a build system, since I used to do similar stuff all the time when I was using
cmake
in a former job.
cmake had all the tools included to check if a file was present, to create one from a template, to copy one from another location and to move or delete files.
I am aware, that ant was capable of performing these tasks, but I'd like to avoid it, since I am pretty sure that this solution would not age well if I am no longer around as the boy that fixes the projects.
In fact, I did solve a rather similar problem that involved downloading files from a server, calculating checksums, writing these checksums to a file and shuffling these files around the project during mavens verify
phase with the antrun plugin. It worked, but maintaining these ant scripts in the future with my coworkers in mind would likely turn into a nightmare - which I would avoid if possible.If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
It's not so much a question of "build system" scope as it is that it is very much not a Java practice to have different ways to compile the same project. Projects that do that do it with a git branch each, and that is all.
I'd check this: https://www.baeldung.com/maven-copy-files
But as usual it's hard as hell to figure out what it supports and I'd probably check the plugin's source code at this point
Baeldung
Copying Files With Maven | Baeldung
Learn how to copy a source file to a destination using three different Maven plugins.
That seems a little bad practice to me, since there would be two branches that would just simply exist to merge commits into them and it would require extreme discipline for everyone not to make changes in the other branches , or merging them back instantly.
That will lead to lots of lost time in my case, since I would constantly be merging shit from one branch to another. But in a different team tis would be the simlest solution of them all. maybe with a little pipeline that does the merging for me 😃
I'm not saying your certification of old libs shenanigans situation didn't put you in a place where different branches would stay a sane approach, I'm telling you you're getting rather far from what is typically done, and as such tools are lacking standardization for these things.
Yeah, I read these, but I seem to be too dumb to do that with something other than the antrun plugin.
The copy rename plugin sis basically the exact hing I would need, but it looks too shady for me. Lacking docs and only have a few posts in a google group...
I also tried the resource plugin, but I had problems, that the files would be absent in the jar, despite being present in the generated target folder that maven places everything in. Probably user error.
At this point you're not asking for file copy plugins, you're asking why the ones you're supposed to use don't do what you want
The situation that copying files around is the most primitive version of solving that problem is not so much my concern, but the two other developers are pretty undisciplined with version control and having pretty poor knowlege of git, so I suspect them to mess up often and I want to avoid a solution that needs constant attention and fixing...
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Basically you are right.
I'm at work tomorrow, maybe I could figure out why the resource plugin does not perform as expected in this thread.
That would solve one item of my endlessly long todo list.
Thanks for your patience so far by the way
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.