[TOOL] Join source files into one (java)


I wrote a small python script to take several java source files and create a single one with correct imports.

There is the link, juste place it in the folder which contains your src folder (or modify the variable srcFolder) and run it. This will create (or replace) a file named packed.java (or modify the variable dstName)


I hope you will find it useful, feel free to improve it or to make it working for other languages and ask for push :slight_smile:

See you


Huge ! Can you make a .bat version ? :smiley:

I won’t since it will make it OS-dependant, what would be the interest ?

Just to not install Python on my computer :wink:

Nice tool :slight_smile:

You could include an exe built with py2exe, I hear it works quite well.

For all java geeks same with maven

just add tag in your children class to remove import with replacel goal, otherwise it will throws errorsin the resulting class :
/begin import/
import java.*;
/end import/

After you just have to execute mvn yuicompressor:compress; mvn replacer:replace;

<?xml version="1.0" encoding="UTF-8"?>


<groupId>your groupid</groupId>
                        <!-- remove files after aggregation (default: false)
                        <!-- insert new line after each concatenation (default: false) -->
                        <!-- files to include, path relative to output's directory or absolute path-->
                        <!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
                            <!-- include your class -->
                        <!-- files to exclude, path relative to output's directory
            <!-- remove your import -->
                <!-- this the token i am using to remove import, you can add your own -->
                <token>\/\*\*begin import\*\*\/.*?\/\*\*end import\*\*\/</token>

Thanks, this is very useful
Not sure why it was not in the original script but I found it necessary to replace “public class” with “class”
sorry for my bad Python:
elif ligne.startswith(‘public class’):
tabCode.append(ligne.replace(‘public class’, ‘class’))