diff --git a/.gitignore b/.gitignore index d20dd6f..567386a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # ---> Gradle .gradle +settings.gradle **/build/ !src/**/build/ diff --git a/src/main/java/speiger/src/builder/base/ConditionedSegment.java b/src/main/java/speiger/src/builder/base/ConditionedSegment.java index f00723d..8ebe26c 100644 --- a/src/main/java/speiger/src/builder/base/ConditionedSegment.java +++ b/src/main/java/speiger/src/builder/base/ConditionedSegment.java @@ -42,7 +42,7 @@ public class ConditionedSegment ConditionedSegment segment = new ConditionedSegment(startIndex); ICondition condition = ICondition.parse(currentLine); List childSegments = new ArrayList<>(); - StringJoiner segmentText = new StringJoiner("\n", "\n", ""); + StringJoiner segmentText = new StringJoiner("\n", (currentIndex <= 0 || includeStartNewLine(lines.get(currentIndex-1).trim())) ? "\n" : "", ""); for(int i = currentIndex+1;i entry : mappings.entrySet()) + List keys = new ArrayList(mappings.keySet()); + keys.sort(String.CASE_INSENSITIVE_ORDER); + for(String s : keys) { - writer.write(entry.getKey()+"="+entry.getValue()); + writer.write(s+"="+mappings.get(s)); writer.newLine(); } writer.flush(); diff --git a/src/main/java/speiger/src/builder/misc/RegexUtil.java b/src/main/java/speiger/src/builder/misc/RegexUtil.java index 75e096f..ebc9165 100644 --- a/src/main/java/speiger/src/builder/misc/RegexUtil.java +++ b/src/main/java/speiger/src/builder/misc/RegexUtil.java @@ -20,6 +20,18 @@ public class RegexUtil return matcher; } + public static int getLastAppendPosition(Matcher matcher) + { + try + { + return LAST_POS.getInt(matcher); + } + catch(Exception e) + { + throw new RuntimeException(e); + } + } + public static String searchUntil(String text, int startIndex, char increase, char decrease) { if(text.charAt(startIndex + 1) != increase) diff --git a/src/main/java/speiger/src/builder/processor/TemplateProcessor.java b/src/main/java/speiger/src/builder/processor/TemplateProcessor.java index 01ae413..a773e51 100644 --- a/src/main/java/speiger/src/builder/processor/TemplateProcessor.java +++ b/src/main/java/speiger/src/builder/processor/TemplateProcessor.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.concurrent.Executors; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -56,6 +57,7 @@ public abstract class TemplateProcessor System.out.println("Nothing has changed"); return false; } + AtomicLong[] counters = new AtomicLong[]{new AtomicLong(), new AtomicLong(), new AtomicLong()}; final boolean relative = relativePackages(); Set[] mappers = debugUnusedMappers() ? new Set[]{Collections.synchronizedSet(new HashSet()), Collections.synchronizedSet(new HashSet())} : null; ThreadPoolExecutor service = (ThreadPoolExecutor)Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); @@ -67,8 +69,11 @@ public abstract class TemplateProcessor Path path = pathsLeft.get(i); try { + long startTime = System.currentTimeMillis(); Template template = Template.parse(path); - createProcesses(FileUtils.getFileName(path), T -> service.execute(new BuildTask(relative ? outputFolder.resolve(sourceFolder.relativize(path).getParent()) : outputFolder, template, T, mappers))); + counters[2].addAndGet(System.currentTimeMillis() - startTime); + counters[1].addAndGet(1); + createProcesses(FileUtils.getFileName(path), T -> {service.execute(new BuildTask(relative ? outputFolder.resolve(sourceFolder.relativize(path).getParent()) : outputFolder, template, T, mappers));counters[0].addAndGet(1);}); } catch(Exception e) { @@ -95,7 +100,7 @@ public abstract class TemplateProcessor System.out.println("Mapper ["+mapper.getSearchValue()+"] is not used in the Entire Build Process"); } } - System.out.println("Finished Tasks: "+(System.currentTimeMillis() - start)+"ms"); + System.out.println("Finished Building ["+counters[0].get()+"] Files from ["+counters[1].get()+"] in "+(System.currentTimeMillis() - start)+"ms (Template Parsing: "+counters[2].get()+"ms (avg: "+((counters[2].get() / Math.max(1D, counters[1].get())))+"ms)"); FileUtils.saveMappings(existing, dataFolder); System.out.print("Saved Changes"); return true;