From d4ddcc92040e908229673b8de3f0e4502ddf5734 Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 23 Oct 2023 18:33:05 +0100 Subject: [PATCH] docs --- .../fluxtion/compiler/FluxtionCompilerConfig.java | 13 +++++++++++++ .../compiler/EventProcessorCompilation.java | 2 +- .../compiler/EventProcessorGenerator.java | 13 ++++++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java b/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java index 42b3ff417..25db8b8ab 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java +++ b/compiler/src/main/java/com/fluxtion/compiler/FluxtionCompilerConfig.java @@ -94,6 +94,10 @@ public class FluxtionCompilerConfig { * The if {@link #writeSourceToFile} is false this writer will capture the content of the generation process */ private Writer sourceWriter; + /** + * Flag controlling adding build time to generated source files + */ + private boolean addBuildTime; private transient ClassLoader classLoader; @@ -101,6 +105,7 @@ public FluxtionCompilerConfig() { generateDescription = false; writeSourceToFile = false; compileSource = true; + addBuildTime = false; formatSource = true; templateSep = JAVA_TEMPLATE; classLoader = FluxtionCompilerConfig.class.getClassLoader(); @@ -157,6 +162,14 @@ public void setWriteSourceToFile(boolean writeSourceToFile) { this.writeSourceToFile = writeSourceToFile; } + public boolean isAddBuildTime() { + return addBuildTime; + } + + public void setAddBuildTime(boolean addBuildTime) { + this.addBuildTime = addBuildTime; + } + public void setPackageName(String packageName) { this.packageName = packageName; } diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java index 83a80f261..ae0fb81c7 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorCompilation.java @@ -105,7 +105,7 @@ private Class generateSep() throws Exception { } EventProcessorGenerator eventProcessorGenerator = new EventProcessorGenerator(); - eventProcessorGenerator.templateSep(builderConfig, compilerConfig.isGenerateDescription(), writer); + eventProcessorGenerator.templateSep(builderConfig, compilerConfig, writer); GenerationContext generationConfig = GenerationContext.SINGLETON; String fqn = generationConfig.getPackageName() + "." + generationConfig.getSepClassName(); File file = new File(generationConfig.getPackageDirectory(), generationConfig.getSepClassName() + ".java"); diff --git a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java index 6bc1ed0c9..5a6f8c2ce 100644 --- a/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java +++ b/compiler/src/main/java/com/fluxtion/compiler/generation/compiler/EventProcessorGenerator.java @@ -18,6 +18,7 @@ package com.fluxtion.compiler.generation.compiler; import com.fluxtion.compiler.EventProcessorConfig; +import com.fluxtion.compiler.FluxtionCompilerConfig; import com.fluxtion.compiler.builder.factory.NodeFactoryLocator; import com.fluxtion.compiler.builder.factory.NodeFactoryRegistration; import com.fluxtion.compiler.generation.GenerationContext; @@ -63,6 +64,7 @@ public class EventProcessorGenerator { private EventProcessorConfig config; private static final Logger LOG = LoggerFactory.getLogger(EventProcessorGenerator.class); private SimpleEventProcessorModel simpleEventProcessorModel; + private FluxtionCompilerConfig compilerConfig; public InMemoryEventProcessor inMemoryProcessor(EventProcessorConfig config, boolean generateDescription) throws Exception { config.buildConfig(); @@ -95,10 +97,11 @@ public InMemoryEventProcessor inMemoryProcessor(EventProcessorConfig config, boo return new InMemoryEventProcessor(simpleEventProcessorModel, config); } - public void templateSep(EventProcessorConfig config, boolean generateDescription, Writer writer) throws Exception { + public void templateSep(EventProcessorConfig config, FluxtionCompilerConfig compilerConfig, Writer writer) throws Exception { ExecutorService execSvc = Executors.newCachedThreadPool(); config.buildConfig(); this.config = config; + this.compilerConfig = compilerConfig; LOG.debug("init velocity"); initVelocity(); LOG.debug("start graph calc"); @@ -117,7 +120,7 @@ public void templateSep(EventProcessorConfig config, boolean generateDescription simpleEventProcessorModel.generateMetaModel(config.isSupportDirtyFiltering()); //TODO add conditionality for different target languages //buildJava output - if (generateDescription) { + if (compilerConfig.isGenerateDescription()) { execSvc.submit(() -> { LOG.debug("start exporting graphML/images"); exportGraphMl(graph); @@ -190,7 +193,11 @@ private void templateJavaOutput(Writer templateWriter) throws Exception { private void addVersionInformation(Context ctx) { ctx.put("generator_version_information", this.getClass().getPackage().getImplementationVersion()); ctx.put("api_version_information", OnEventHandler.class.getPackage().getImplementationVersion()); - ctx.put("build_time", LocalDateTime.now()); + if (compilerConfig.isAddBuildTime()) { + ctx.put("build_time", LocalDateTime.now()); + } else { + ctx.put("build_time", "Not available"); + } } public static void formatSource(File outFile) {