Created
February 20, 2015 19:12
-
-
Save Naios/cceb5b0346daef5cb075 to your computer and use it in GitHub Desktop.
Source group creator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import java.io.PrintWriter; | |
import java.util.Arrays; | |
/** | |
* @author Naios <[email protected]> | |
*/ | |
public class SourceGroupCreator | |
{ | |
public static void main(final String[] args) | |
{ | |
final File current; | |
if (args.length != 0) | |
current = new File(args[args.length - 1]); | |
else | |
current = new File(System.getProperty("user.dir")); | |
System.out.println("Working dir: " + current + "\n-------------------------------------"); | |
if (!current.isDirectory()) | |
{ | |
System.out.println("no directory!"); | |
return; | |
} | |
final File target; | |
try | |
{ | |
target = new File(current.getPath() + "/source_group.txt"); | |
target.createNewFile(); | |
} | |
catch (final Exception e) | |
{ | |
e.printStackTrace(); | |
return; | |
} | |
try (final PrintWriter writer = new PrintWriter(target, "UTF-8")) | |
{ | |
Arrays.<File>asList(current.listFiles()) | |
.stream() | |
.filter(file -> file.isDirectory()) | |
.forEach(file -> | |
{ | |
System.out.println(file); | |
writer.printf("source_group(%s FILES ${sources_%s})\n", file.getName(), file.getName()); | |
}); | |
writer.close(); | |
} | |
catch (final Exception e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment