I am looking for a library which would simplify the process of copying parts of the code from one project to another. Copying of certain parts of the code which belong to the same file is not required. I am aware that there exists some code generators which would enable me to build the generated code from scratch programatically, but I am looking for a library which would enable me to generate already hand-coded code elsewhere.
I would prefer an annotation-based tool which would enable me to "tag" the classes/files/packages I would like to copy. Something like this:
@CopyCode
class Foo {
...
}
File destinationDirectory;
...
new CodeCopier().copyAllAnnotatedFiles(destinationDirectory);
or at least something like:
Package package;
...
new CodeCopier().copyPackage(package, destinationDirectory);
Expected behavior: The source code of the file which contains the "tagged" code should be copied to the destination directory (which is another Java project), with all the directory/package structure maintained.
Is there any library which would be helpful here?
If not, what is your advice, how should I implement my own "code copier" and what libraries would come in handy?