diff --git a/.github/workflows/A-build-and-test-jdk11.yml b/.github/workflows/A-build-and-test-jdk11.yml index db7fc4c0..a02e0e97 100644 --- a/.github/workflows/A-build-and-test-jdk11.yml +++ b/.github/workflows/A-build-and-test-jdk11.yml @@ -36,7 +36,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/.github/workflows/A-build-and-test-jdk17.yml b/.github/workflows/A-build-and-test-jdk17.yml index 700455df..d8f23ffe 100644 --- a/.github/workflows/A-build-and-test-jdk17.yml +++ b/.github/workflows/A-build-and-test-jdk17.yml @@ -36,7 +36,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/.github/workflows/A-build-and-test-jdk21.yml b/.github/workflows/A-build-and-test-jdk21.yml index 21c97491..7be375c5 100644 --- a/.github/workflows/A-build-and-test-jdk21.yml +++ b/.github/workflows/A-build-and-test-jdk21.yml @@ -36,7 +36,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/.github/workflows/A-build-and-test.yml b/.github/workflows/A-build-and-test.yml index fe799d5d..1b011da0 100644 --- a/.github/workflows/A-build-and-test.yml +++ b/.github/workflows/A-build-and-test.yml @@ -36,7 +36,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/.github/workflows/B-combatibility-tests.yml b/.github/workflows/B-combatibility-tests.yml index 3720276e..33745ae4 100644 --- a/.github/workflows/B-combatibility-tests.yml +++ b/.github/workflows/B-combatibility-tests.yml @@ -36,7 +36,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/.github/workflows/D-release-openclover.yml b/.github/workflows/D-release-openclover.yml index 10b269c6..936e2917 100644 --- a/.github/workflows/D-release-openclover.yml +++ b/.github/workflows/D-release-openclover.yml @@ -31,7 +31,6 @@ jobs: - name: Prepare third party libraries run: | - mvn --batch-mode install -f clover-core-libs/jarjar/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-core-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn --batch-mode install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/README.md b/README.md index f4c66d34..a8cf047a 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,6 @@ See also: ### Prepare repacked third party libraries ``` -mvn install -f clover-core-libs/jarjar/pom.xml mvn install -Pworkspace-setup -f clover-core-libs/pom.xml mvn install -Pworkspace-setup -f clover-eclipse-libs/pom.xml mvn install -Pworkspace-setup -f clover-idea-libs/pom.xml diff --git a/clover-all/pom.xml b/clover-all/pom.xml index 1f7cb02a..68b1eea6 100644 --- a/clover-all/pom.xml +++ b/clover-all/pom.xml @@ -105,8 +105,8 @@ jfreechart - org.openclover - clover-velocity + org.apache.velocity + velocity diff --git a/clover-core-libs/clover-velocity/pom.xml b/clover-core-libs/clover-velocity/pom.xml deleted file mode 100644 index cd6fd3db..00000000 --- a/clover-core-libs/clover-velocity/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - 4.0.0 - clover-velocity - 1.7 - jar - - org.openclover - clover-core-libs - 5.0.0-SNAPSHOT - ../pom.xml - - - Repacked with 'clover.' prefix version of the library. - - - - Apache 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - OpenClover Velocity Library - - - - workspace-setup - - - org.apache.velocity - velocity - ${project.version} - - - - clover-velocity-${project.version}.jar - - - - - org.apache.maven.plugins - maven-antrun-plugin - - - - com.tonicsystems - jarjar - 1.4 - - - - - package - - run - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/clover-core-libs/jarjar/pom.xml b/clover-core-libs/jarjar/pom.xml deleted file mode 100644 index d2322f55..00000000 --- a/clover-core-libs/jarjar/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - 4.0.0 - com.tonicsystems - jarjar - 1.4 - - A JARJAR 1.4 downloaded from https://jarjar.googlecode.com/files/jarjar-1.4.jar - - - - Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 - - - JARJAR - - - - org.apache.maven.plugins - maven-antrun-plugin - - - package - - run - - - - - - - - - - - org.apache.maven.plugins - maven-install-plugin - - - install - - install-file - - - ${project.build.directory}/jarjar-${project.version}.jar - pom.xml - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - - deploy - - deploy-file - - - ${project.build.directory}/jarjar-${project.version}.jar - pom.xml - - - - - - - diff --git a/clover-core-libs/pom.xml b/clover-core-libs/pom.xml index 75d604c5..cb1f7936 100644 --- a/clover-core-libs/pom.xml +++ b/clover-core-libs/pom.xml @@ -29,7 +29,6 @@ cajo fastutil - clover-velocity diff --git a/clover-core/pom.xml b/clover-core/pom.xml index 59e37c1f..85b40efd 100644 --- a/clover-core/pom.xml +++ b/clover-core/pom.xml @@ -87,8 +87,8 @@ jfreechart - org.openclover - clover-velocity + org.apache.velocity + velocity @@ -345,7 +345,7 @@ org.jfree:jcommon jdom:jdom org.jfree:jfreechart - org.openclover:clover-velocity + org.apache.velocity:velocity @@ -357,6 +357,9 @@ commons-collections:commons-collections + + org/apache/commons/collections/** + META-INF/LICENSE.txt META-INF/MANIFEST.MF @@ -371,6 +374,12 @@ commons-lang:commons-lang + + + org/apache/commons/lang/* + org/apache/commons/lang/builder/* + org/apache/commons/lang/text/* + META-INF/LICENSE.txt META-INF/MANIFEST.MF @@ -401,17 +410,27 @@ com.lowagie:itext META-INF/MANIFEST.MF + ant/* build.xml org.jfree:jcommon + + + org/jfree/** + META-INF/MANIFEST.MF org.jfree:jfreechart + + + org/jfree/chart/** + org/jfree/data/** + META-INF/MANIFEST.MF @@ -420,12 +439,23 @@ jdom:jdom META-INF/MANIFEST.MF + META-INF/LICENSE.txt + META-INF/info.xml - org.openclover:clover-velocity + org.apache.velocity:velocity + + + org/apache/velocity/** + META-INF/MANIFEST.MF + META-INF/NOTICE + + **/directive.properties + **/velocity.properties + **/texen.properties @@ -474,6 +504,13 @@ org.apache.commons.lang3.** + + org.apache.velocity + clover.org.apache.velocity + + org.apache.velocity.** + + org.jdom clover.org.jdom diff --git a/clover-core/src/main/java/org/openclover/core/reporters/CloudGenerator.java b/clover-core/src/main/java/org/openclover/core/reporters/CloudGenerator.java index 2de4321a..72acc6c5 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/CloudGenerator.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/CloudGenerator.java @@ -1,11 +1,11 @@ package org.openclover.core.reporters; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.registry.metrics.HasMetricsSupport; import org.openclover.core.reporters.html.ClassInfoStatsCalculator; import org.openclover.core.reporters.html.HtmlReportUtil; import org.openclover.core.reporters.html.StatisticsClassInfoVisitor; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.spi.reporters.html.source.HtmlRenderingSupport; import java.io.IOException; @@ -24,13 +24,14 @@ public class CloudGenerator { protected final String template; protected final HtmlRenderingSupport axisRendering; protected final OutputStream outputStream; - protected final VelocityContext velocityContext; + protected final VelocityContextBuilder velocityContext; public CloudGenerator(String template, HtmlRenderingSupport axisRendering, OutputStream outputStream) { - this(template, axisRendering, outputStream, new VelocityContext()); + this(template, axisRendering, outputStream, VelocityContextBuilder.create()); } - public CloudGenerator(String template, HtmlRenderingSupport axisRendering, OutputStream outputStream, VelocityContext velocityContext) { + public CloudGenerator(String template, HtmlRenderingSupport axisRendering, OutputStream outputStream, + VelocityContextBuilder velocityContext) { this.template = template; this.axisRendering = axisRendering; this.outputStream = outputStream; @@ -50,7 +51,7 @@ public final void createReport(List classes, protected final void applyAxis(List classes, ClassInfoStatsCalculator axis1, ClassInfoStatsCalculator axis2, - VelocityContext context) { + VelocityContextBuilder context) { StatisticsClassInfoVisitor v2 = StatisticsClassInfoVisitor.visit(sort(classes), axis2); StatisticsClassInfoVisitor v1 = StatisticsClassInfoVisitor.visit(v2.getClasses(), axis1); context.put(DEEPAXIS, Boolean.TRUE); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReportUtil.java b/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReportUtil.java index 18b1deb3..e5ed4955 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReportUtil.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReportUtil.java @@ -1,8 +1,8 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; -import clover.org.apache.velocity.app.Velocity; -import clover.org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.app.Velocity; +import org.apache.velocity.app.VelocityEngine; +import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; import org.openclover.core.api.registry.HasMetrics; import org.openclover.core.reporters.Column; import org.openclover.core.reporters.ColumnFormat; @@ -20,20 +20,22 @@ import java.util.List; public class HtmlReportUtil { - private static ThreadLocal ve = ThreadLocal.withInitial(HtmlReportUtil::newVelocityEngine); + private static final ThreadLocal ve = ThreadLocal.withInitial(() -> HtmlReportUtil.newVelocityEngine(true)); public static VelocityEngine getVelocityEngine() { - return (VelocityEngine) ve.get(); + return ve.get(); } - static VelocityEngine newVelocityEngine() { + public static VelocityEngine newVelocityEngine(boolean withClasspathLoader) { VelocityEngine engine = new VelocityEngine(); try { engine.setProperty("resource.loader", "class"); engine.setProperty("velocimacro.library", ""); engine.setProperty( "class.resource.loader.class", - clover.org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader.class.getName()); + withClasspathLoader + ? ClasspathResourceLoader.class.getName() + : PlainTextVelocityResourceLoader.class.getName()); engine.setProperty("class.resource.loader.cache", "true"); engine.setProperty("class.resource.loader.modificationCheckInterval", "0"); engine.setProperty("parser.pool.size", "1"); @@ -48,22 +50,23 @@ static VelocityEngine newVelocityEngine() { return engine; } - /** The number of extra columns used when rendering tables * containing {@link Columns}.**/ static final int EXTRA_COLS = 1; - public static void mergeTemplateToFile(VelocityEngine engine, File outfile, VelocityContext context, String template) throws IOException { + public static void mergeTemplateToFile(VelocityEngine engine, File outfile, + VelocityContextBuilder context, String template) throws IOException { mergeTemplateToStream(engine, Files.newOutputStream(outfile.toPath()), context, template); } - public static void mergeTemplateToStream(VelocityEngine engine, OutputStream outputStream, VelocityContext context, String template) { + public static void mergeTemplateToStream(VelocityEngine engine, OutputStream outputStream, + VelocityContextBuilder context, String template) { if (Logger.isDebug()) Logger.getInstance().debug("rendering " + template); try (BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8))) { - if (engine.mergeTemplate(template, "ASCII", context, out)) { + if (engine.mergeTemplate(template, "ASCII", context.build(), out)) { if (Logger.isDebug()) { Logger.getInstance().debug("done "); } @@ -78,22 +81,22 @@ public static void mergeTemplateToStream(VelocityEngine engine, OutputStream out } - public static void mergeTemplateToFile(File outfile, VelocityContext context, String template) throws IOException { + public static void mergeTemplateToFile(File outfile, VelocityContextBuilder context, String template) throws IOException { mergeTemplateToFile(getVelocityEngine(), outfile, context, getTemplatePath(template)); } - public static void mergeTemplateToStream(OutputStream outputStream, VelocityContext context, String template) throws IOException { + public static void mergeTemplateToStream(OutputStream outputStream, VelocityContextBuilder context, String template) throws IOException { mergeTemplateToStream(getVelocityEngine(), outputStream, context, getTemplatePath(template)); } - public static void mergeTemplateToDir(File basePath, String templateName, VelocityContext context) throws IOException { + public static void mergeTemplateToDir(File basePath, String templateName, VelocityContextBuilder context) throws IOException { File outfile = new File(basePath, templateName); context.put("currentPageURL", templateName); mergeTemplateToFile(outfile, context, templateName); } - public static void addColumnsToContext(VelocityContext context, List cols, HasMetrics parent, List children) { + public static void addColumnsToContext(VelocityContextBuilder context, List cols, HasMetrics parent, List children) { HasMetrics childInfo = children != null && children.size() > 0 ? children.get(0) : null; context.put("columns", cols); int colSpan = EXTRA_COLS; @@ -104,10 +107,9 @@ public static void addColumnsToContext(VelocityContext context, List col context.put("colSpan", colSpan); context.put("headerInfo", parent); context.put("childHeaderInfo", childInfo); - } - public static void addFilteredPercentageToContext(VelocityContext context, HasMetrics model) { + public static void addFilteredPercentageToContext(VelocityContextBuilder context, HasMetrics model) { float pcFiltered = getPercentageFiltered(model); if (pcFiltered > 0) { String percentFiltered = Formatting.getPercentStr(pcFiltered); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReporter.java b/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReporter.java index 776dc747..baa40991 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReporter.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/HtmlReporter.java @@ -1,7 +1,6 @@ package org.openclover.core.reporters.html; import org.apache.commons.lang3.StringUtils; -import clover.org.apache.velocity.VelocityContext; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; @@ -328,7 +327,7 @@ private void executeHistoricalReport() throws Exception { coverageTS = new Date(descriptor.getFirstTimestamp()); filterLinkedReports(); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); insertCommonPropsForHistorical(context, ""); HtmlReportUtil.mergeTemplateToDir(basePath, "style.css", context); @@ -451,15 +450,15 @@ public static int runReport(String[] args) { return 1; } - private VelocityContext insertCommonPropsForCurrent(VelocityContext context, String pkg) { + private VelocityContextBuilder insertCommonPropsForCurrent(VelocityContextBuilder context, String pkg) { return insertCommonProps(context, pkg); } - private VelocityContext insertCommonPropsForHistorical(VelocityContext context, String pkg) { + private VelocityContextBuilder insertCommonPropsForHistorical(VelocityContextBuilder context, String pkg) { return insertCommonProps(context, pkg); } - private VelocityContext insertCommonProps(VelocityContext context, String pkg) { + private VelocityContextBuilder insertCommonProps(VelocityContextBuilder context, String pkg) { context.put("fileUtils", FileUtils.getInstance()); context.put("stringUtils", new StringUtils()); @@ -494,13 +493,13 @@ private VelocityContext insertCommonProps(VelocityContext context, String pkg) { } private void renderProjectCoverageCloudPage(TreeInfo appCloudTree, CloverExecutor service) throws Exception { - VelocityContext cloudsContext = new VelocityContext(); + VelocityContextBuilder cloudsContext = VelocityContextBuilder.create(); insertCommonPropsForCurrent(cloudsContext, ""); service.submit(new RenderProjectCoverageCloudsAction(cloudsContext, reportConfig, basePath, appCloudTree, getConfiguredModel())); } private void renderProjectTreeMapPage(CloverExecutor service) throws Exception { - VelocityContext context = new VelocityContext(); + VelocityContextBuilder context = VelocityContextBuilder.create(); insertCommonPropsForCurrent(context, ""); service.submit(new RenderTreeMapAction(context, basePath, getConfiguredModel())); } @@ -518,7 +517,7 @@ protected ProjectInfo getTestModel() { } private void renderPackageNodesTree(CloverExecutor queue) throws Exception { - VelocityContext ctx = new VelocityContext(); + VelocityContextBuilder ctx = VelocityContextBuilder.create(); insertCommonPropsForCurrent(ctx, ""); RenderPackageTreeJsonAction action = new RenderPackageTreeJsonAction(ctx, basePath, getFullModel(), getConfiguredModel(), reportAsCurrent()); @@ -526,7 +525,7 @@ private void renderPackageNodesTree(CloverExecutor queue) throws Excepti } private void renderDashboard(CloverExecutor queue, CloverChartFactory.ChartInfo histogram, CloverChartFactory.ChartInfo scatter) throws Exception { - VelocityContext ctx = new VelocityContext(); + final VelocityContextBuilder ctx = VelocityContextBuilder.create(); insertCommonPropsForCurrent(ctx, ""); final ProjectInfo configuredProject = getConfiguredModel(); RenderDashboardAction action = new RenderDashboardAction(ctx, basePath, configuredProject, getFullModel(), @@ -711,7 +710,7 @@ private void renderSourceFilePage(final CloverExecutor queue, file, rederingHelper, reportAsCurrent(), - insertCommonPropsForCurrent(new VelocityContext(), file.getContainingPackage().getName()), + insertCommonPropsForCurrent(VelocityContextBuilder.create(), file.getContainingPackage().getName()), database, projectInfo, charts)); @@ -726,7 +725,7 @@ private void renderTestPages(CloverExecutor queue, FileInfo fileInfo) th continue; } for (TestCaseInfo test : classInfo.getTestCases()) { - VelocityContext context = new VelocityContext(); + VelocityContextBuilder context = VelocityContextBuilder.create(); insertCommonPropsForCurrent(context, fileInfo.getContainingPackage().getName()); Callable testResultRenderer = new RenderTestResultAction( @@ -750,7 +749,7 @@ private void renderAggregatePkgPage(ProjectInfo model, TreeInfo tree, boolean li final String filename = tree.getPathPrefix() + "agg-pkgs.html"; final File outfile = new File(basePath, filename); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); context.put("linkToClouds", linkToClouds); context.put("currentPageURL", filename); context.put("headerMetrics", model.getMetrics()); @@ -778,7 +777,7 @@ private void renderAggregatePkgPage(ProjectInfo model, TreeInfo tree, boolean li private void renderBasePages() throws Exception { File outfile = new File(basePath, reportConfig.getMainFileName()); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); context.put("currentPageURL", reportConfig.getMainFileName()); insertCommonPropsForCurrent(context, ""); @@ -804,7 +803,7 @@ private String getHomepageValue() { return HTML_HOMEPAGE_VALUES.getOrDefault(homepageKey, homepageKey); } - private void renderPackagesSummaryPage(String name, String templateName, VelocityContext context, + private void renderPackagesSummaryPage(String name, String templateName, VelocityContextBuilder context, ProjectInfo model, TreeInfo tree, boolean linkToClouds) throws Exception { final String filename = tree.getPathPrefix() + name; final File outfile = new File(basePath, filename); @@ -833,12 +832,12 @@ private void renderPackagesSummaryPage(String name, String templateName, Velocit private void renderPackagesSummaryPage(ProjectInfo model, TreeInfo tree, boolean linkToClouds) throws Exception { renderPackagesSummaryPage("pkg-summary.html", "pkgs-summary.vm", - new VelocityContext(), model, tree, linkToClouds); + VelocityContextBuilder.create(), model, tree, linkToClouds); } private void renderTestResultsPkgsSummaryPage() throws Exception { final File outfile = new File(basePath, "test-pkg-summary.html"); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); final ProjectInfo projectInfo = getFullModel().copy( hasMetrics -> @@ -863,7 +862,7 @@ private void renderPkgClassesPage( String templateName, PackageInfo pkg, List classes, - VelocityContext context, + VelocityContextBuilder context, String currentTabName, boolean isTests) throws Exception { @@ -892,20 +891,21 @@ public static String renderHtmlBarTable(float pcCovered, int width, String custo public static String renderHtmlBarTable(float pcCovered, int width, String customClass, String customBarPositive, String customBarNegative) throws Exception { - final VelocityContext context = new VelocityContext(); - context.put("empty", pcCovered < 0); - context.put("pccovered", pcCovered); - context.put("sortValue", pcCovered); - context.put("width", width); - context.put("customClass", customClass); - context.put("customBarPositive", customBarPositive); - context.put("customBarNegative", customBarNegative); - context.put("renderUtil", new HtmlRenderingSupportImpl()); + final VelocityContextBuilder context = VelocityContextBuilder.create() + .put("empty", pcCovered < 0) + .put("pccovered", pcCovered) + .put("sortValue", pcCovered) + .put("width", width) + .put("customClass", customClass) + .put("customBarPositive", customBarPositive) + .put("customBarNegative", customBarNegative) + .put("renderUtil", new HtmlRenderingSupportImpl()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(baos, StandardCharsets.UTF_8)); - HtmlReportUtil.getVelocityEngine().mergeTemplate( - HtmlReportUtil.getTemplatePath("bar-graph.vm"), "ASCII", context, out); + HtmlReportUtil + .getVelocityEngine() + .mergeTemplate(HtmlReportUtil.getTemplatePath("bar-graph.vm"), "ASCII", context.build(), out); out.close(); return baos.toString(); @@ -914,7 +914,7 @@ public static String renderHtmlBarTable(float pcCovered, int width, private void renderPkgSummaryPage(PackageInfo pkg, TreeInfo tree, boolean appPagePresent, boolean testPagePresent, boolean linkToClouds, CloverExecutor queue) throws Exception { - VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); insertCommonPropsForCurrent(context, pkg.getName()); queue.submit( @@ -925,7 +925,7 @@ private void renderPkgSummaryPage(PackageInfo pkg, TreeInfo tree, private void renderPkgCloudPages(PackageInfo pkg, TreeInfo tree, boolean appPagePresent, boolean testPagePresent, CloverExecutor queue) throws Exception { - VelocityContext context = new VelocityContext(); + VelocityContextBuilder context = VelocityContextBuilder.create(); insertCommonPropsForCurrent(context, pkg.getName()); queue.submit( @@ -953,7 +953,7 @@ private void renderTestResultsPkgSummaryPages(@NotNull PackageInfo pkg, classes.sort(TEST_SORT_ORDER); final File outfile = new File(outdir, "test-pkg-summary.html"); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); context.put("currentPageURL", "test-pkg-summary.html"); context.put("projectInfo", getFullModel()); @@ -977,7 +977,7 @@ private void renderTestClassSummaryPage(@NotNull ClassInfo classInfo) throws Exc tests.sort(TEST_CASE_COMPARATOR); - final VelocityContext context = new VelocityContext(); + final VelocityContextBuilder context = VelocityContextBuilder.create(); context.put("currentPageURL", outName); @@ -993,7 +993,7 @@ private void renderTestClassSummaryPage(@NotNull ClassInfo classInfo) throws Exc } private void insertCommonTestProps( - VelocityContext context, + VelocityContextBuilder context, List entities, String childEntityType, PackageInfo pkg, diff --git a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/PlainTextVelocityResourceLoader.java b/clover-core/src/main/java/org/openclover/core/reporters/html/PlainTextVelocityResourceLoader.java similarity index 79% rename from clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/PlainTextVelocityResourceLoader.java rename to clover-core/src/main/java/org/openclover/core/reporters/html/PlainTextVelocityResourceLoader.java index 97a89acf..2618ae39 100644 --- a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/PlainTextVelocityResourceLoader.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/PlainTextVelocityResourceLoader.java @@ -1,7 +1,7 @@ -package org.openclover.eclipse.core.views.dashboard; +package org.openclover.core.reporters.html; -import clover.org.apache.velocity.exception.ResourceNotFoundException; -import clover.org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; +import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader; import java.io.InputStream; import java.util.Set; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderCoverageCloudAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderCoverageCloudAction.java index 280a0101..213ab092 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderCoverageCloudAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderCoverageCloudAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.reporters.CloverReportConfig; @@ -14,11 +13,11 @@ public abstract class RenderCoverageCloudAction implements Callable { protected final List classes; protected final File basePath; - protected final VelocityContext context; + protected final VelocityContextBuilder context; protected final CloverReportConfig reportConfig; protected final HtmlReporter.TreeInfo tree; - public RenderCoverageCloudAction(VelocityContext context, CloverReportConfig reportConfig, + public RenderCoverageCloudAction(VelocityContextBuilder context, CloverReportConfig reportConfig, HtmlReporter.TreeInfo tree, List classes, File basePath) { this.context = context; this.reportConfig = reportConfig; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderDashboardAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderDashboardAction.java index bb0beb0b..2991d3d1 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderDashboardAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderDashboardAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.api.registry.ProjectInfo; import org.openclover.core.registry.metrics.HasMetricsSupport; @@ -28,17 +27,17 @@ public class RenderDashboardAction implements Callable { private final File mBasePath; // share - read only private final ProjectInfo mConfiguredInfo; // shared - read only private final ProjectInfo mProjectInfo; // shared - read only - private final VelocityContext mContext; // not shared, read/write + private final VelocityContextBuilder mContext; // not shared, read/write private final CloverChartFactory.ChartInfo mHistogram; private final CloverChartFactory.ChartInfo mScatter; private final Current reportConfig; - public RenderDashboardAction(VelocityContext ctx, File basePath, ProjectInfo configured, ProjectInfo full, + public RenderDashboardAction(VelocityContextBuilder context, File basePath, ProjectInfo configured, ProjectInfo full, CloverChartFactory.ChartInfo histogram, CloverChartFactory.ChartInfo scatter, Current reportConfig) { mBasePath = basePath; mConfiguredInfo = configured; mProjectInfo = full; - mContext = ctx; + mContext = context; mHistogram = histogram; mScatter = scatter; this.reportConfig = reportConfig; @@ -55,7 +54,7 @@ protected File insertDashboardProperties() throws Exception { // get data required for dashboard if (Boolean.TRUE != mContext.get("skipCoverageTreeMap")) { // render the package level treemap - final RenderTreeMapAction tree = new RenderTreeMapAction(new VelocityContext(), mBasePath, mConfiguredInfo); + final RenderTreeMapAction tree = new RenderTreeMapAction(VelocityContextBuilder.create(), mBasePath, mConfiguredInfo); tree.renderTreeMapJson("treemap-dash-json.js", "processTreeMapDashJson", false); } final List classes = mConfiguredInfo.getClasses(new TestClassCoverageThresholdFilter()); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderFileAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderFileAction.java index ba50ddff..2f86cf2a 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderFileAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderFileAction.java @@ -1,7 +1,6 @@ package org.openclover.core.reporters.html; import antlr.TokenStreamException; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.BitSetCoverageProvider; import org.openclover.core.CloverDatabase; import org.openclover.core.CoverageData; @@ -57,7 +56,7 @@ public class RenderFileAction implements Callable { protected final FileInfo fileInfo; // shared: call made to setDataProvider on local copy protected final HtmlRenderingSupportImpl renderingHelper; // shared - has static Pattern(thread safe) objects. protected final Current reportConfig; // shared - read only - protected final VelocityContext velocity; // not shared + protected final VelocityContextBuilder velocity; // not shared protected final CloverDatabase database; /// shared - read + write to cache in mDb.getRegistry().getContextsAsString - synchronized cache there. protected final ProjectInfo fullModel; // shared - call buildCaches first! protected final Map charts; @@ -67,7 +66,7 @@ public RenderFileAction( FileInfo fileInfo, HtmlRenderingSupportImpl renderingHelper, Current report, - VelocityContext velocity, + VelocityContextBuilder velocity, CloverDatabase database, ProjectInfo fullModel, Map charts) { diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageCoverageCloudAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageCoverageCloudAction.java index 8fa4f5df..d5fad96d 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageCoverageCloudAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageCoverageCloudAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.api.registry.HasMetrics; import org.openclover.core.api.registry.PackageInfo; @@ -19,7 +18,7 @@ public class RenderPackageCoverageCloudAction extends RenderCoverageCloudAction private final boolean appPagePresent; private final boolean testPagePresent; - public RenderPackageCoverageCloudAction(VelocityContext context, CloverReportConfig reportConfig, + public RenderPackageCoverageCloudAction(VelocityContextBuilder context, CloverReportConfig reportConfig, File basePath, HtmlReporter.TreeInfo tree, PackageInfo pkg, boolean appPagePresent, boolean testPagePresent) { super(context, reportConfig, tree, sortedClassesFor(pkg), basePath); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageSummaryAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageSummaryAction.java index 77e00047..2b0702db 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageSummaryAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageSummaryAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.api.registry.HasMetrics; import org.openclover.core.api.registry.PackageInfo; @@ -15,7 +14,7 @@ import java.util.concurrent.Callable; public class RenderPackageSummaryAction implements Callable { - private final VelocityContext context; + private final VelocityContextBuilder context; private final File basePath; private final PackageInfo pkg; private final boolean appPagePresent; @@ -27,7 +26,7 @@ public class RenderPackageSummaryAction implements Callable { private final List columns; private final HtmlRenderingSupport helper; - public RenderPackageSummaryAction(VelocityContext context, File basePath, CloverReportConfig cfg, PackageInfo pkg, + public RenderPackageSummaryAction(VelocityContextBuilder context, File basePath, CloverReportConfig cfg, PackageInfo pkg, Comparator detailComparator, HtmlReporter.TreeInfo tree, HtmlRenderingSupport helper, boolean appPagePresent, boolean testPagePresent, boolean linkToClouds) { this.context = context; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageTreeJsonAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageTreeJsonAction.java index 9147c194..5f33fc7a 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageTreeJsonAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderPackageTreeJsonAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.PackageInfo; import org.openclover.core.api.registry.ProjectInfo; import org.openclover.core.registry.metrics.HasMetricsSupport; @@ -20,12 +19,12 @@ public class RenderPackageTreeJsonAction implements Callable { private final ProjectInfo fullProjectInfo; // shared - read only private final ProjectInfo appProjectInfo; // shared - read only - private final VelocityContext context; // not shared, read/write + private final VelocityContextBuilder context; // not shared, read/write private final Current reportConfig; private final File basePath; - public RenderPackageTreeJsonAction(VelocityContext ctx, File basePath, + public RenderPackageTreeJsonAction(VelocityContextBuilder ctx, File basePath, ProjectInfo fullProjectInfo, ProjectInfo appProjectInfo, Current reportConfig) { this.basePath = basePath; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderProjectCoverageCloudsAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderProjectCoverageCloudsAction.java index b7b24915..a9080a75 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderProjectCoverageCloudsAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderProjectCoverageCloudsAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.api.registry.ProjectInfo; import org.openclover.core.registry.metrics.HasMetricsSupport; @@ -12,12 +11,12 @@ public class RenderProjectCoverageCloudsAction extends RenderCoverageCloudAction { protected ProjectInfo projectInfo; - public RenderProjectCoverageCloudsAction(VelocityContext context, CloverReportConfig reportConfig, + public RenderProjectCoverageCloudsAction(VelocityContextBuilder context, CloverReportConfig reportConfig, File basePath, HtmlReporter.TreeInfo tree, ProjectInfo projectInfo) { this(context, reportConfig, basePath, tree, projectInfo, sortedAppClassesFor(projectInfo)); } - public RenderProjectCoverageCloudsAction(VelocityContext context, CloverReportConfig reportConfig, + public RenderProjectCoverageCloudsAction(VelocityContextBuilder context, CloverReportConfig reportConfig, File basePath, HtmlReporter.TreeInfo tree, ProjectInfo projectInfo, List classes) { super(context, reportConfig, tree, classes, basePath); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderTestResultAction.java b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderTestResultAction.java index a98b44db..53a74fbb 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/RenderTestResultAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/RenderTestResultAction.java @@ -1,7 +1,6 @@ package org.openclover.core.reporters.html; import org.apache.commons.lang3.StringUtils; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.BitSetCoverageProvider; import org.openclover.core.CloverDatabase; import org.openclover.core.CoverageData; @@ -34,7 +33,7 @@ public class RenderTestResultAction implements Callable { private final Current reportConfig; // read only private final ProjectInfo fullModel; // read only - put into velocity context for rendering private final TestCaseInfo testCaseInfo; // read only - private final VelocityContext velocity; // write only + private final VelocityContextBuilder velocity; // write only private final CloverDatabase database; // shared but read only private final ProjectInfo readOnlyModel; // gets copied in thread locals @@ -44,7 +43,7 @@ public RenderTestResultAction( HtmlRenderingSupportImpl renderingHelper, Current reportConfig, ProjectInfo readOnlyModel, - VelocityContext velocity, + VelocityContextBuilder velocity, ProjectInfo fullModel, CloverDatabase database) { diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityContextBuilder.java b/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityContextBuilder.java new file mode 100644 index 00000000..a1e08c60 --- /dev/null +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityContextBuilder.java @@ -0,0 +1,28 @@ +package org.openclover.core.reporters.html; + +import org.apache.velocity.VelocityContext; + +public class VelocityContextBuilder { + + private final VelocityContext context = new VelocityContext(); + + private VelocityContextBuilder() { + } + + public static VelocityContextBuilder create() { + return new VelocityContextBuilder(); + } + + public VelocityContextBuilder put(String key, Object value) { + context.put(key, value); + return this; + } + + public VelocityContext build() { + return context; + } + + public Object get(String key) { + return context.get(key); + } +} diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityLogAdapter.java b/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityLogAdapter.java index 09163432..69720f45 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityLogAdapter.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/VelocityLogAdapter.java @@ -1,7 +1,7 @@ package org.openclover.core.reporters.html; -import clover.org.apache.velocity.runtime.RuntimeServices; -import clover.org.apache.velocity.runtime.log.LogChute; +import org.apache.velocity.runtime.RuntimeServices; +import org.apache.velocity.runtime.log.LogChute; import org.openclover.runtime.Logger; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/html/source/SourceRenderHelper.java b/clover-core/src/main/java/org/openclover/core/reporters/html/source/SourceRenderHelper.java index b5eb1100..03bb876e 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/html/source/SourceRenderHelper.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/html/source/SourceRenderHelper.java @@ -1,20 +1,19 @@ package org.openclover.core.reporters.html.source; import org.apache.commons.lang3.StringUtils; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.CloverDatabase; import org.openclover.core.api.registry.BranchInfo; import org.openclover.core.api.registry.ContextSet; +import org.openclover.core.api.registry.CoverageDataProvider; import org.openclover.core.api.registry.ElementInfo; import org.openclover.core.api.registry.FileInfo; import org.openclover.core.api.registry.SourceInfo; -import org.openclover.core.api.registry.CoverageDataProvider; import org.openclover.core.api.registry.TestCaseInfo; import org.openclover.core.registry.entities.LineInfo; - import org.openclover.core.reporters.Current; import org.openclover.core.reporters.html.HtmlRenderingSupportImpl; import org.openclover.core.reporters.html.JSONObjectFactory; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.spi.reporters.html.source.LineRenderInfo; import org.openclover.core.spi.reporters.html.source.SourceRenderer; import org.openclover.core.util.ChecksummingReader; @@ -65,7 +64,7 @@ public SourceRenderHelper(CloverDatabase database, Current report, HtmlRendering this.tabStr = StringUtils.repeat(spaceChar, report.getFormat().getTabWidth()); } - public void insertLineInfosForFile(FileInfo fileInfo, VelocityContext context, ContextSet contextSet, String emptyChar, List[] testLineInfo) { + public void insertLineInfosForFile(FileInfo fileInfo, VelocityContextBuilder context, ContextSet contextSet, String emptyChar, List[] testLineInfo) { try { LineRenderInfo[] renderInfo = gatherSrcRenderInfo(context, fileInfo, contextSet, emptyChar, testLineInfo); context.put("renderInfo", renderInfo); @@ -85,12 +84,12 @@ public void insertLineInfosForFile(FileInfo fileInfo, VelocityContext context, C } } - private void putErrorMessage(VelocityContext context, String message) { + private void putErrorMessage(VelocityContextBuilder context, String message) { context.put("errormsg", message); } @SuppressWarnings("unchecked") - private void addWarning(VelocityContext context, String message) { + private void addWarning(VelocityContextBuilder context, String message) { List warningMessages = (List) context.get("warningMessages"); if (warningMessages == null) { warningMessages = newArrayList(); @@ -111,7 +110,7 @@ private void addWarning(VelocityContext context, String message) { * @throws antlr.TokenStreamException * if an error occurs reading the source file */ - public LineRenderInfo[] gatherSrcRenderInfo(VelocityContext vc, FileInfo finfo, ContextSet contextSet, + public LineRenderInfo[] gatherSrcRenderInfo(VelocityContextBuilder vc, FileInfo finfo, ContextSet contextSet, String emptyCoverageChar, List[] testLineInfo) throws Exception { // remove the failed test coverage filter at the file level... diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/JSONHistoricalReporter.java b/clover-core/src/main/java/org/openclover/core/reporters/json/JSONHistoricalReporter.java index 07610c5c..9ce584cb 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/JSONHistoricalReporter.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/JSONHistoricalReporter.java @@ -1,10 +1,10 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.HasMetrics; import org.openclover.core.reporters.Column; import org.openclover.core.reporters.Columns; import org.openclover.core.reporters.html.HtmlReportUtil; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.runtime.Logger; import org.openclover.runtime.api.CloverException; @@ -60,7 +60,7 @@ public JSONHistoricalReporter(File basePath) { * @param data the map of historical data points * @throws Exception if an error occurs while writing the JSON */ - public void generateHistoricalJSON(VelocityContext context, Map data, String title) throws Exception { + public void generateHistoricalJSON(VelocityContextBuilder context, Map data, String title) throws Exception { final JSONObject json = generateJSON(data, title); final File jsonOutfile = new File(mBasePath, "historical-json.js"); context.put("json", json.toString(2)); diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/JSONReporter.java b/clover-core/src/main/java/org/openclover/core/reporters/json/JSONReporter.java index 3243b750..b8b81073 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/JSONReporter.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/JSONReporter.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.command.ArgProcessor; import org.openclover.core.api.command.HelpBuilder; import org.openclover.core.api.registry.FileInfo; @@ -12,6 +11,7 @@ import org.openclover.core.reporters.Current; import org.openclover.core.reporters.Format; import org.openclover.core.reporters.html.HtmlRenderingSupportImpl; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.util.CloverExecutor; import org.openclover.core.util.CloverExecutors; import org.openclover.core.util.CloverUtils; @@ -86,11 +86,11 @@ public int executeImpl() throws CloverException { RenderMetricsJSONAction.initThreadLocals(); service.submit( - new RenderColophonJSONAction(new VelocityContext(), new File(getConfigAsCurrent().getOutFile(), "colophon.js"), getConfigAsCurrent())); + new RenderColophonJSONAction(VelocityContextBuilder.create(), new File(getConfigAsCurrent().getOutFile(), "colophon.js"), getConfigAsCurrent())); service.submit( new RenderMetricsJSONAction( - new VelocityContext(), + VelocityContextBuilder.create(), projectInfo, getConfigAsCurrent(), new File(getConfigAsCurrent().getOutFile(), "project.js"), @@ -99,13 +99,13 @@ public int executeImpl() throws CloverException { service.submit( new RenderCloudsJSONAction.ForProjects.OfTheirRisks( projectInfo, - new VelocityContext(), + VelocityContextBuilder.create(), getConfigAsCurrent(), getConfigAsCurrent().getOutFile())); service.submit( new RenderCloudsJSONAction.ForProjects.OfTheirQuickWins( projectInfo, - new VelocityContext(), + VelocityContextBuilder.create(), getConfigAsCurrent(), getConfigAsCurrent().getOutFile())); @@ -156,16 +156,26 @@ private void processPackage(PackageInfo pkg, CloverExecutor service) throws Exce final File basedir = CloverUtils.createOutDir(pkg, getConfigAsCurrent().getOutFile()); final File outfile = new File(basedir, "package.js"); - service.submit(new RenderMetricsJSONAction(new VelocityContext(), pkg, getConfigAsCurrent(), outfile, renderingHelper)); - service.submit(new RenderCloudsJSONAction.ForPackages.OfTheirRisks(new VelocityContext(), pkg, getConfigAsCurrent(), basedir, true)); - service.submit(new RenderCloudsJSONAction.ForPackages.OfTheirRisks(new VelocityContext(), pkg, getConfigAsCurrent(), basedir, false)); - service.submit(new RenderCloudsJSONAction.ForPackages.OfTheirQuickWins(new VelocityContext(), pkg, getConfigAsCurrent(), basedir, true)); - service.submit(new RenderCloudsJSONAction.ForPackages.OfTheirQuickWins(new VelocityContext(), pkg, getConfigAsCurrent(), basedir, false)); + service.submit( + new RenderMetricsJSONAction( + VelocityContextBuilder.create(), pkg, getConfigAsCurrent(), outfile, renderingHelper)); + service.submit( + new RenderCloudsJSONAction.ForPackages.OfTheirRisks( + VelocityContextBuilder.create(), pkg, getConfigAsCurrent(), basedir, true)); + service.submit( + new RenderCloudsJSONAction.ForPackages.OfTheirRisks( + VelocityContextBuilder.create(), pkg, getConfigAsCurrent(), basedir, false)); + service.submit( + new RenderCloudsJSONAction.ForPackages.OfTheirQuickWins( + VelocityContextBuilder.create(), pkg, getConfigAsCurrent(), basedir, true)); + service.submit( + new RenderCloudsJSONAction.ForPackages.OfTheirQuickWins( + VelocityContextBuilder.create(), pkg, getConfigAsCurrent(), basedir, false)); for (FileInfo file : files) { service.submit( new RenderFileJSONAction( - file, renderingHelper, getConfigAsCurrent(), new VelocityContext(), database, projectInfo)); + file, renderingHelper, getConfigAsCurrent(), VelocityContextBuilder.create(), database, projectInfo)); } } diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderCloudsJSONAction.java b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderCloudsJSONAction.java index 8af7b8ef..79b1fc67 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderCloudsJSONAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderCloudsJSONAction.java @@ -1,15 +1,15 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ClassInfo; +import org.openclover.core.api.registry.HasMetricsFilter; import org.openclover.core.api.registry.PackageInfo; import org.openclover.core.api.registry.ProjectInfo; -import org.openclover.core.api.registry.HasMetricsFilter; import org.openclover.core.registry.metrics.HasMetricsSupport; import org.openclover.core.reporters.CloverReportConfig; import org.openclover.core.reporters.html.ClassInfoStatsCalculator; import org.openclover.core.reporters.html.HtmlReportUtil; import org.openclover.core.reporters.html.StatisticsClassInfoVisitor; +import org.openclover.core.reporters.html.VelocityContextBuilder; import java.io.File; import java.util.List; @@ -23,10 +23,10 @@ public abstract class RenderCloudsJSONAction implements Callable { protected final File dir; protected final CloverReportConfig cfg; - protected final VelocityContext ctx; + protected final VelocityContextBuilder ctx; protected final boolean aggregate; - public RenderCloudsJSONAction(VelocityContext ctx, CloverReportConfig cfg, File dir, boolean aggregate) { + public RenderCloudsJSONAction(VelocityContextBuilder ctx, CloverReportConfig cfg, File dir, boolean aggregate) { this.cfg = cfg; this.dir = dir; this.ctx = ctx; @@ -74,13 +74,13 @@ protected List sort(List classes) { public abstract static class ForProjects extends RenderCloudsJSONAction { protected final ProjectInfo project; - protected ForProjects(ProjectInfo project, VelocityContext ctx, CloverReportConfig cfg, File dir) { + protected ForProjects(ProjectInfo project, VelocityContextBuilder ctx, CloverReportConfig cfg, File dir) { super(ctx, cfg, dir, false); this.project = project; } public static class OfTheirRisks extends ForProjects { - public OfTheirRisks(ProjectInfo project, VelocityContext ctx, CloverReportConfig cfg, File dir) { + public OfTheirRisks(ProjectInfo project, VelocityContextBuilder ctx, CloverReportConfig cfg, File dir) { super(project, ctx, cfg, dir); } @@ -95,7 +95,7 @@ public Object call() throws Exception { } } public static class OfTheirQuickWins extends ForProjects { - public OfTheirQuickWins(ProjectInfo project, VelocityContext ctx, CloverReportConfig cfg, File dir) { + public OfTheirQuickWins(ProjectInfo project, VelocityContextBuilder ctx, CloverReportConfig cfg, File dir) { super(project, ctx, cfg, dir); } @@ -114,13 +114,13 @@ public Object call() throws Exception { public abstract static class ForPackages extends RenderCloudsJSONAction { protected final PackageInfo pkg; - protected ForPackages(VelocityContext ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { + protected ForPackages(VelocityContextBuilder ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { super(ctx, cfg, dir, aggregate); this.pkg = pkg; } public static class OfTheirRisks extends ForPackages { - public OfTheirRisks(VelocityContext ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { + public OfTheirRisks(VelocityContextBuilder ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { super(ctx, pkg, cfg, dir, aggregate); } @@ -136,7 +136,7 @@ public Object call() throws Exception { } public static class OfTheirQuickWins extends ForPackages { - public OfTheirQuickWins(VelocityContext ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { + public OfTheirQuickWins(VelocityContextBuilder ctx, PackageInfo pkg, CloverReportConfig cfg, File dir, boolean aggregate) { super(ctx, pkg, cfg, dir, aggregate); } diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderColophonJSONAction.java b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderColophonJSONAction.java index 361c7c05..7f055fda 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderColophonJSONAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderColophonJSONAction.java @@ -1,8 +1,8 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.reporters.CloverReportConfig; import org.openclover.core.reporters.html.HtmlReportUtil; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org_openclover_runtime.CloverVersionInfo; import java.io.File; @@ -12,11 +12,11 @@ import java.util.concurrent.Callable; public class RenderColophonJSONAction implements Callable { - private final VelocityContext ctx; + private final VelocityContextBuilder ctx; private final File file; private final CloverReportConfig cfg; - public RenderColophonJSONAction(VelocityContext ctx, File file, CloverReportConfig cfg) { + public RenderColophonJSONAction(VelocityContextBuilder ctx, File file, CloverReportConfig cfg) { this.ctx = ctx; this.file = file; this.cfg = cfg; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderFileJSONAction.java b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderFileJSONAction.java index 55202c04..61cae17f 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderFileJSONAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderFileJSONAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.CloverDatabase; import org.openclover.core.api.registry.FileInfo; import org.openclover.core.api.registry.ProjectInfo; @@ -9,6 +8,7 @@ import org.openclover.core.reporters.html.HtmlRenderingSupportImpl; import org.openclover.core.reporters.html.HtmlReportUtil; import org.openclover.core.reporters.html.RenderFileAction; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.reporters.html.source.SourceRenderHelper; import org.openclover.core.spi.reporters.html.source.LineRenderInfo; import org.openclover.core.util.CloverUtils; @@ -22,7 +22,7 @@ public class RenderFileJSONAction extends RenderFileAction { public RenderFileJSONAction(FileInfo fileInfo, HtmlRenderingSupportImpl renderingHelper, Current report, - VelocityContext velocity, CloverDatabase database, ProjectInfo fullModel) { + VelocityContextBuilder velocity, CloverDatabase database, ProjectInfo fullModel) { super(fileInfo, renderingHelper, report, velocity, database, fullModel, null); } diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderMetricsJSONAction.java b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderMetricsJSONAction.java index f738e1e3..18d14656 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderMetricsJSONAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderMetricsJSONAction.java @@ -1,6 +1,5 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.FileInfo; import org.openclover.core.api.registry.HasMetrics; import org.openclover.core.api.registry.PackageInfo; @@ -9,6 +8,7 @@ import org.openclover.core.reporters.Columns; import org.openclover.core.reporters.html.HtmlRenderingSupportImpl; import org.openclover.core.reporters.html.HtmlReportUtil; +import org.openclover.core.reporters.html.VelocityContextBuilder; import java.io.File; import java.util.List; @@ -24,11 +24,11 @@ public class RenderMetricsJSONAction implements Callable { private final File mFile; private final HtmlRenderingSupportImpl mHelper; private final CloverReportConfig mCfg; - private final VelocityContext mCtx; + private final VelocityContextBuilder mCtx; public RenderMetricsJSONAction( - VelocityContext ctx, HasMetrics configured, - CloverReportConfig current, File outfile, HtmlRenderingSupportImpl helper) { + VelocityContextBuilder ctx, HasMetrics configured, + CloverReportConfig current, File outfile, HtmlRenderingSupportImpl helper) { mInfo = configured; mCtx = ctx; mHelper = helper; diff --git a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderTreeMapAction.java b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderTreeMapAction.java index f279c0b4..2f993c8e 100644 --- a/clover-core/src/main/java/org/openclover/core/reporters/json/RenderTreeMapAction.java +++ b/clover-core/src/main/java/org/openclover/core/reporters/json/RenderTreeMapAction.java @@ -1,9 +1,9 @@ package org.openclover.core.reporters.json; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ProjectInfo; import org.openclover.core.reporters.html.HtmlRenderingSupportImpl; import org.openclover.core.reporters.html.HtmlReportUtil; +import org.openclover.core.reporters.html.VelocityContextBuilder; import java.io.File; import java.util.concurrent.Callable; @@ -12,10 +12,10 @@ public class RenderTreeMapAction implements Callable { private final ProjectInfo project; private final File outdir; - private final VelocityContext mContext; + private final VelocityContextBuilder mContext; private final HtmlRenderingSupportImpl renderSupport = new HtmlRenderingSupportImpl(); - public RenderTreeMapAction(VelocityContext context, File outdir, ProjectInfo project) { + public RenderTreeMapAction(VelocityContextBuilder context, File outdir, ProjectInfo project) { this.project = project; this.outdir = outdir; this.mContext = context; diff --git a/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/directive.properties b/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/directive.properties new file mode 100644 index 00000000..bcb072b0 --- /dev/null +++ b/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/directive.properties @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +directive.1=clover.org.apache.velocity.runtime.directive.Foreach +directive.2=clover.org.apache.velocity.runtime.directive.Include +directive.3=clover.org.apache.velocity.runtime.directive.Parse +directive.4=clover.org.apache.velocity.runtime.directive.Macro +directive.5=clover.org.apache.velocity.runtime.directive.Literal +directive.6=clover.org.apache.velocity.runtime.directive.Evaluate +directive.7=clover.org.apache.velocity.runtime.directive.Break +directive.8=clover.org.apache.velocity.runtime.directive.Define +directive.9=clover.org.apache.velocity.runtime.directive.Stop diff --git a/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/velocity.properties b/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/velocity.properties new file mode 100644 index 00000000..e7af437c --- /dev/null +++ b/clover-core/src/main/resources/clover/org/apache/velocity/runtime/defaults/velocity.properties @@ -0,0 +1,269 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# ---------------------------------------------------------------------------- +# R U N T I M E L O G +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# default LogChute to use: default: AvalonLogChute, Log4JLogChute, CommonsLogLogChute, ServletLogChute, JdkLogChute +# ---------------------------------------------------------------------------- + +runtime.log.logsystem.class = clover.org.apache.velocity.runtime.log.AvalonLogChute,clover.org.apache.velocity.runtime.log.Log4JLogChute,clover.org.apache.velocity.runtime.log.CommonsLogLogChute,clover.org.apache.velocity.runtime.log.ServletLogChute,clover.org.apache.velocity.runtime.log.JdkLogChute + +# --------------------------------------------------------------------------- +# This is the location of the Velocity Runtime log. +# ---------------------------------------------------------------------------- + +runtime.log = velocity.log + +# ---------------------------------------------------------------------------- +# This controls whether invalid references are logged. +# ---------------------------------------------------------------------------- + +runtime.log.invalid.references = true + +# ---------------------------------------------------------------------------- +# T E M P L A T E E N C O D I N G +# ---------------------------------------------------------------------------- + +input.encoding=ISO-8859-1 +output.encoding=ISO-8859-1 + +# ---------------------------------------------------------------------------- +# F O R E A C H P R O P E R T I E S +# ---------------------------------------------------------------------------- +# These properties control how the counter is accessed in the #foreach +# directive. By default the reference $velocityCount and $velocityHasNext +# will be available in the body of the #foreach directive. +# The default starting value for $velocityCount is 1. +# ---------------------------------------------------------------------------- + +directive.foreach.counter.name = velocityCount +directive.foreach.counter.initial.value = 1 +directive.foreach.maxloops = -1 + +directive.foreach.iterator.name = velocityHasNext + +# ---------------------------------------------------------------------------- +# S E T P R O P E R T I E S +# ---------------------------------------------------------------------------- +# These properties control the behavior of #set. +# For compatibility, the default behavior is to disallow setting a reference +# to null. This default may be changed in a future version. +# ---------------------------------------------------------------------------- + +directive.set.null.allowed = false + +# ---------------------------------------------------------------------------- +# I F P R O P E R T I E S +# ---------------------------------------------------------------------------- +# These properties control the behavior of #if +# Default behavior is to check return value of toString() and treat an object +# with toString() that returns null as null. If all objects have toString() +# methods that never return null, this check is unnecessary and can be disabled +# to gain performance. In Velocity 1.5, no such null check was performed. +directive.if.tostring.nullcheck = true + +# ---------------------------------------------------------------------------- +# I N C L U D E P R O P E R T I E S +# ---------------------------------------------------------------------------- +# These are the properties that governed the way #include'd content +# is governed. +# ---------------------------------------------------------------------------- + +directive.include.output.errormsg.start = + +# ---------------------------------------------------------------------------- +# P A R S E P R O P E R T I E S +# ---------------------------------------------------------------------------- + +directive.parse.max.depth = 10 + +# ---------------------------------------------------------------------------- +# S C O P E P R O P E R T I E S +# ---------------------------------------------------------------------------- +# These are the properties that govern whether or not a Scope object +# is automatically provided for each of the given scopes to serve as a +# scope-safe reference namespace and "label" for #break calls. The default +# for most of these is false. Note that should be replaced by +# name of macros that take bodies for which you want to suppress the scope. +# ---------------------------------------------------------------------------- +# template.provide.scope.control = false +# evaluate.provide.scope.control = false +foreach.provide.scope.control = true +# macro.provide.scope.control = false +# define.provide.scope.control = false +# .provide.scope.control = false + +# ---------------------------------------------------------------------------- +# T E M P L A T E L O A D E R S +# ---------------------------------------------------------------------------- +# +# +# ---------------------------------------------------------------------------- + +resource.loader = file + +file.resource.loader.description = Velocity File Resource Loader +file.resource.loader.class = clover.org.apache.velocity.runtime.resource.loader.FileResourceLoader +file.resource.loader.path = . +file.resource.loader.cache = false +file.resource.loader.modificationCheckInterval = 2 + +string.resource.loader.description = Velocity String Resource Loader +string.resource.loader.class = clover.org.apache.velocity.runtime.resource.loader.StringResourceLoader + +# ---------------------------------------------------------------------------- +# VELOCIMACRO PROPERTIES +# ---------------------------------------------------------------------------- +# global : name of default global library. It is expected to be in the regular +# template path. You may remove it (either the file or this property) if +# you wish with no harm. +# ---------------------------------------------------------------------------- +# velocimacro.library = VM_global_library.vm + +velocimacro.permissions.allow.inline = true +velocimacro.permissions.allow.inline.to.replace.global = false +velocimacro.permissions.allow.inline.local.scope = false + +velocimacro.context.localscope = false +velocimacro.max.depth = 20 + +# ---------------------------------------------------------------------------- +# VELOCIMACRO STRICT MODE +# ---------------------------------------------------------------------------- +# if true, will throw an exception for incorrect number +# of arguments. false by default (for backwards compatibility) +# but this option will eventually be removed and will always +# act as if true +# ---------------------------------------------------------------------------- +velocimacro.arguments.strict = false + +# ---------------------------------------------------------------------------- +# VELOCIMACRO BODY REFERENCE +# ---------------------------------------------------------------------------- +# Defines name of the reference that can be used to render the AST block passed to +# block macro call as an argument inside a macro. +# ---------------------------------------------------------------------------- +velocimacro.body.reference=bodyContent + +# ---------------------------------------------------------------------------- +# STRICT REFERENCE MODE +# ---------------------------------------------------------------------------- +# if true, will throw a MethodInvocationException for references +# that are not defined in the context, or have not been defined +# with a #set directive. This setting will also throw an exception +# if an attempt is made to call a non-existing property on an object +# or if the object is null. When this property is true then property +# 'directive.set.null.allowed' is also set to true. +# ---------------------------------------------------------------------------- +runtime.references.strict = false + +# ---------------------------------------------------------------------------- +# INTERPOLATION +# ---------------------------------------------------------------------------- +# turn off and on interpolation of references and directives in string +# literals. ON by default :) +# ---------------------------------------------------------------------------- +runtime.interpolate.string.literals = true + + +# ---------------------------------------------------------------------------- +# RESOURCE MANAGEMENT +# ---------------------------------------------------------------------------- +# Allows alternative ResourceManager and ResourceCache implementations +# to be plugged in. +# ---------------------------------------------------------------------------- +resource.manager.class = clover.org.apache.velocity.runtime.resource.ResourceManagerImpl +resource.manager.cache.class = clover.org.apache.velocity.runtime.resource.ResourceCacheImpl + +# ---------------------------------------------------------------------------- +# PARSER POOL +# ---------------------------------------------------------------------------- +# Selects a custom factory class for the parser pool. Must implement +# ParserPool. parser.pool.size is used by the default implementation +# ParserPoolImpl +# ---------------------------------------------------------------------------- + +parser.pool.class = clover.org.apache.velocity.runtime.ParserPoolImpl +parser.pool.size = 20 + + +# ---------------------------------------------------------------------------- +# EVENT HANDLER +# ---------------------------------------------------------------------------- +# Allows alternative event handlers to be plugged in. Note that each +# class property is actually a comma-separated list of classes (which will +# be called in order). +# ---------------------------------------------------------------------------- +# eventhandler.referenceinsertion.class = +# eventhandler.nullset.class = +# eventhandler.methodexception.class = +# eventhandler.include.class = + + +# ---------------------------------------------------------------------------- +# EVALUATE +# ---------------------------------------------------------------------------- +# Evaluate VTL dynamically in template. Select a class for the Context, if +# you want all #set calls within it to be locally scoped. This feature is +# deprecated; please use $evaluate to hold local references instead. +# ---------------------------------------------------------------------------- + +#directive.evaluate.context.class = clover.org.apache.velocity.VelocityContext + + +# ---------------------------------------------------------------------------- +# PLUGGABLE INTROSPECTOR +# ---------------------------------------------------------------------------- +# Allows alternative introspection and all that can of worms brings. +# ---------------------------------------------------------------------------- + +runtime.introspector.uberspect = clover.org.apache.velocity.util.introspection.UberspectImpl + + +# ---------------------------------------------------------------------------- +# SECURE INTROSPECTOR +# ---------------------------------------------------------------------------- +# If selected, prohibits methods in certain classes and packages from being +# accessed. +# ---------------------------------------------------------------------------- + +introspector.restrict.packages = java.lang.reflect + +# The two most dangerous classes + +introspector.restrict.classes = java.lang.Class +introspector.restrict.classes = java.lang.ClassLoader + +# Restrict these for extra safety + +introspector.restrict.classes = java.lang.Compiler +introspector.restrict.classes = java.lang.InheritableThreadLocal +introspector.restrict.classes = java.lang.Package +introspector.restrict.classes = java.lang.Process +introspector.restrict.classes = java.lang.Runtime +introspector.restrict.classes = java.lang.RuntimePermission +introspector.restrict.classes = java.lang.SecurityManager +introspector.restrict.classes = java.lang.System +introspector.restrict.classes = java.lang.Thread +introspector.restrict.classes = java.lang.ThreadGroup +introspector.restrict.classes = java.lang.ThreadLocal + + diff --git a/clover-core/src/main/resources/clover/org/apache/velocity/texen/defaults/texen.properties b/clover-core/src/main/resources/clover/org/apache/velocity/texen/defaults/texen.properties new file mode 100644 index 00000000..6e3c2661 --- /dev/null +++ b/clover-core/src/main/resources/clover/org/apache/velocity/texen/defaults/texen.properties @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +path.output=output +context.objects.strings=clover.org.apache.velocity.util.StringUtils +context.objects.files=clover.org.apache.velocity.texen.util.FileUtil +context.objects.properties=clover.org.apache.velocity.texen.util.PropertiesUtil diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderActionTest.groovy index 50e27e80..157007a4 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html -import clover.org.apache.velocity.VelocityContext import junit.framework.TestCase import org.openclover.core.TestUtils import org.openclover.core.api.registry.ProjectInfo @@ -12,13 +11,13 @@ import org.openclover.core.reporters.util.CloverChartFactory class RenderActionTest extends TestCase { - VelocityContext context + VelocityContextBuilder context Current config HasMetricsTestFixture fixture File basePath void setUp() throws IOException { - context = new VelocityContext() + context = VelocityContextBuilder.create() basePath = TestUtils.createEmptyDirFor(getClass(), getName()) String initStr = basePath.getAbsolutePath() + "/clover.db" diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderFileActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderFileActionTest.groovy index 716c78e6..d7e3a524 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderFileActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderFileActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html -import clover.org.apache.velocity.VelocityContext import junit.framework.TestCase import org.openclover.core.CloverDatabase import org.openclover.core.api.registry.PackageInfo @@ -43,7 +42,7 @@ class RenderFileActionTest extends TestCase { void testInsertSrcFileProperties() throws Exception { HtmlRenderingSupportImpl helper = new HtmlRenderingSupportImpl() - VelocityContext ctx = new VelocityContext() + VelocityContextBuilder ctx = VelocityContextBuilder.create() PackageInfo pinfo = fixture.newPackage("com.clover.test") FullFileInfo finfo = fixture.newFile(pinfo, "TestFileInfo.java") diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderProjectCoverageCloudsActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderProjectCoverageCloudsActionTest.groovy index 8a258958..48e775c6 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderProjectCoverageCloudsActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderProjectCoverageCloudsActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html -import clover.org.apache.velocity.VelocityContext import junit.framework.TestCase import org.openclover.core.api.registry.BranchInfo import org.openclover.core.api.registry.ContextSet @@ -16,11 +15,9 @@ import org.openclover.core.reporters.Current import static org.openclover.core.util.Lists.newArrayList -/** - */ class RenderProjectCoverageCloudsActionTest extends TestCase { - private VelocityContext ctx + private VelocityContextBuilder ctx private HtmlReporter.TreeInfo tree private List classes private File basePath @@ -44,7 +41,7 @@ class RenderProjectCoverageCloudsActionTest extends TestCase { * @throws java.io.IOException */ protected void setUp() throws IOException { - ctx = new VelocityContext() + ctx = VelocityContextBuilder.create() reportConfig = new Current() tree = new HtmlReporter.TreeInfo("pathPrefix", "name") classes = newArrayList() diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderTestResultActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderTestResultActionTest.groovy index 0720bffd..a82cd485 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderTestResultActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/html/RenderTestResultActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.html -import clover.org.apache.velocity.VelocityContext import junit.framework.TestCase import org.openclover.core.CloverDatabase import org.openclover.core.api.registry.PackageInfo @@ -39,7 +38,7 @@ class RenderTestResultActionTest extends TestCase { config.setShowUniqueCoverage(true) - VelocityContext ctx = new VelocityContext() + VelocityContextBuilder ctx = VelocityContextBuilder.create() PackageInfo pinfo = fixture.newPackage("com.clover.test") FullFileInfo finfo = fixture.newFile(pinfo, "TestFileInfo.java") @@ -66,7 +65,7 @@ class RenderTestResultActionTest extends TestCase { void testRenderWithoutUniqueCoverage() throws Exception { HtmlRenderingSupportImpl helper = new HtmlRenderingSupportImpl() - VelocityContext ctx = new VelocityContext() + VelocityContextBuilder ctx = VelocityContextBuilder.create() PackageInfo pinfo = fixture.newPackage("com.clover.test") FullFileInfo finfo = fixture.newFile(pinfo, "TestFileInfo.java") diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderFileJSONActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderFileJSONActionTest.groovy index 633b150a..a1de7df6 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderFileJSONActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderFileJSONActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.json -import clover.org.apache.velocity.VelocityContext import junit.framework.TestCase import org.openclover.core.CloverDatabase import org.openclover.core.api.registry.PackageInfo @@ -10,6 +9,7 @@ import org.openclover.core.registry.metrics.HasMetricsTestFixture import org.openclover.core.registry.metrics.PackageMetrics import org.openclover.core.reporters.Current import org.openclover.core.reporters.html.HtmlRenderingSupportImpl +import org.openclover.core.reporters.html.VelocityContextBuilder import org.openclover.core.util.CloverUtils import org.openclover.runtime.api.CloverException @@ -44,7 +44,7 @@ class RenderFileJSONActionTest extends TestCase { void testRenderJSON() throws Exception { HtmlRenderingSupportImpl helper = new HtmlRenderingSupportImpl() - VelocityContext ctx = new VelocityContext() + VelocityContextBuilder ctx = VelocityContextBuilder.create() PackageInfo pinfo = fixture.newPackage("com.clover.test") FullFileInfo finfo = fixture.newFile(pinfo, "TestFileInfo.java") @@ -63,7 +63,7 @@ class RenderFileJSONActionTest extends TestCase { void testRenderMetricsJSON() throws Exception { HtmlRenderingSupportImpl helper = new HtmlRenderingSupportImpl() - VelocityContext ctx = new VelocityContext() + VelocityContextBuilder ctx = VelocityContextBuilder.create() PackageInfo pinfo = fixture.newPackage("com.clover.test") fixture.newFile(pinfo, "TestFileInfo.java") diff --git a/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderTreeMapActionTest.groovy b/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderTreeMapActionTest.groovy index a6ce7233..27262a5d 100644 --- a/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderTreeMapActionTest.groovy +++ b/clover-core/src/test/groovy/org/openclover/core/reporters/json/RenderTreeMapActionTest.groovy @@ -1,6 +1,5 @@ package org.openclover.core.reporters.json -import clover.org.apache.velocity.VelocityContext import org.junit.Before import org.junit.Test import org.openclover.core.TestUtils @@ -16,6 +15,7 @@ import org.openclover.core.registry.metrics.ProjectMetrics import org.openclover.core.reporters.CloverReportConfig import org.openclover.core.reporters.Current import org.openclover.core.reporters.Format +import org.openclover.core.reporters.html.VelocityContextBuilder import java.util.concurrent.Callable @@ -38,7 +38,7 @@ class RenderTreeMapActionTest { void testCall() throws Exception { final ProjectInfo project = createMockProject() - final VelocityContext context = new VelocityContext() + final VelocityContextBuilder context = VelocityContextBuilder.create() final CloverReportConfig reportConfig = new Current() reportConfig.setFormat(Format.DEFAULT_HTML) final Callable action = new RenderTreeMapAction(context, tmpDir, project) diff --git a/clover-eclipse/org.openclover.eclipse.core/pom.xml b/clover-eclipse/org.openclover.eclipse.core/pom.xml index c0c1e33a..fb9498fd 100644 --- a/clover-eclipse/org.openclover.eclipse.core/pom.xml +++ b/clover-eclipse/org.openclover.eclipse.core/pom.xml @@ -21,7 +21,7 @@ org.openclover - clover-core + clover ${clover.version} diff --git a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/ui/editors/cloud/EclipseCloudGenerator.java b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/ui/editors/cloud/EclipseCloudGenerator.java index e689883c..93040a1a 100644 --- a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/ui/editors/cloud/EclipseCloudGenerator.java +++ b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/ui/editors/cloud/EclipseCloudGenerator.java @@ -1,6 +1,5 @@ package org.openclover.eclipse.core.ui.editors.cloud; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.CloverDatabase; import org.openclover.core.api.registry.ClassInfo; import org.openclover.core.api.registry.PackageInfo; @@ -9,6 +8,7 @@ import org.openclover.core.reporters.html.ClassInfoStatsCalculator; import org.openclover.core.reporters.html.HtmlReportUtil; import org.openclover.core.reporters.html.TestClassFilter; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.util.CloverUtils; import org.openclover.eclipse.core.CloverEclipsePluginMessages; @@ -95,7 +95,7 @@ public void execute() throws Exception { } private void createResources() throws Exception { - VelocityContext context = new VelocityContext(); + VelocityContextBuilder context = VelocityContextBuilder.create(); HtmlReportUtil.mergeTemplateToDir(basePath, "style.css", context); } @@ -136,10 +136,10 @@ protected CloudGenerator createReportGenerator( OutputStream outputStream, EclipseEditorLinkingHtmlRenderingSupport axisRenderer) throws IOException { - final VelocityContext context = new VelocityContext(); - context.put("baseUrl", basePath.toURI().toURL().toExternalForm()); - context.put("showSrc", Boolean.TRUE); - context.put("title", pageTitle); + final VelocityContextBuilder context = VelocityContextBuilder.create() + .put("baseUrl", basePath.toURI().toURL().toExternalForm()) + .put("showSrc", Boolean.TRUE) + .put("title", pageTitle); return new CloudGenerator(TEMPLATE, axisRenderer, outputStream, context); } diff --git a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/DashboardGenerator.java b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/DashboardGenerator.java index 3d0a9346..a7d3f699 100644 --- a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/DashboardGenerator.java +++ b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/DashboardGenerator.java @@ -1,14 +1,11 @@ package org.openclover.eclipse.core.views.dashboard; -import clover.org.apache.velocity.VelocityContext; -import clover.org.apache.velocity.app.Velocity; -import clover.org.apache.velocity.app.VelocityEngine; import org.openclover.core.CloverDatabase; import org.openclover.core.reporters.Current; import org.openclover.core.reporters.html.HtmlReportUtil; -import org.openclover.core.reporters.html.VelocityLogAdapter; +import org.openclover.core.reporters.html.PlainTextVelocityResourceLoader; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.util.FileUtils; -import org.openclover.runtime.Logger; import java.io.File; import java.io.IOException; @@ -36,12 +33,11 @@ public DashboardGenerator(CloverDatabase database, File basePath) { public void execute() throws Exception { createResources(); - final VelocityContext context = new VelocityContext(); - - context.put("baseUrl", getBaseURL()); - context.put("rootRelPath", ""); - context.put("showSrc", Boolean.TRUE); - context.put("skipCoverageTreeMap", Boolean.TRUE); + final VelocityContextBuilder context = VelocityContextBuilder.create() + .put("baseUrl", getBaseURL()) + .put("rootRelPath", "") + .put("showSrc", Boolean.TRUE) + .put("skipCoverageTreeMap", Boolean.TRUE); final Current currentConfig = new Current(); currentConfig.setShowLambdaFunctions(false); @@ -54,22 +50,8 @@ public void execute() throws Exception { mergePlainTextTemplateToFile(dashboardFile, context, DASHBOARD_VM); } - static void mergePlainTextTemplateToFile(File outfile, VelocityContext context, String template) throws Exception { - final VelocityEngine engine = new VelocityEngine(); - engine.setProperty("resource.loader", "class"); - engine.setProperty("velocimacro.library", ""); - engine.setProperty( - "class.resource.loader.class", - PlainTextVelocityResourceLoader.class.getName()); - engine.setProperty("class.resource.loader.cache", "true"); - engine.setProperty("class.resource.loader.modificationCheckInterval", "0"); - engine.setProperty("parser.pool.size", "1"); - engine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new VelocityLogAdapter(Logger.getInstance())); - engine.setProperty("resource.manager.logwhenfound", "false"); - engine.setProperty("runtime.log.invalid.references", "false"); - engine.init(); - - HtmlReportUtil.mergeTemplateToFile(engine, outfile, context, template); + static void mergePlainTextTemplateToFile(File outfile, VelocityContextBuilder context, String template) throws Exception { + HtmlReportUtil.mergeTemplateToFile(HtmlReportUtil.newVelocityEngine(false), outfile, context, template); } public String getDashboardURL() { diff --git a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/RenderEclipseDashboardAction.java b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/RenderEclipseDashboardAction.java index 49b4bbf0..16b48cfe 100644 --- a/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/RenderEclipseDashboardAction.java +++ b/clover-eclipse/org.openclover.eclipse.core/src/main/java/org/openclover/eclipse/core/views/dashboard/RenderEclipseDashboardAction.java @@ -1,19 +1,19 @@ package org.openclover.eclipse.core.views.dashboard; -import clover.org.apache.velocity.VelocityContext; import org.openclover.core.api.registry.ProjectInfo; import org.openclover.core.reporters.Current; import org.openclover.core.reporters.html.RenderDashboardAction; +import org.openclover.core.reporters.html.VelocityContextBuilder; import org.openclover.core.reporters.util.CloverChartFactory.ChartInfo; import java.io.File; public class RenderEclipseDashboardAction extends RenderDashboardAction { - public RenderEclipseDashboardAction(VelocityContext ctx, File basePath, + public RenderEclipseDashboardAction(VelocityContextBuilder contextFactory, File basePath, ProjectInfo configured, ProjectInfo full, ChartInfo histogram, ChartInfo scatter, Current currentConfig) { - super(ctx, basePath, configured, full, histogram, scatter, currentConfig); + super(contextFactory, basePath, configured, full, histogram, scatter, currentConfig); } public void applyCtxChanges() throws Exception { diff --git a/clover-groovy/pom.xml b/clover-groovy/pom.xml index cb5e54c2..009ba688 100644 --- a/clover-groovy/pom.xml +++ b/clover-groovy/pom.xml @@ -210,8 +210,8 @@ cajo - org.openclover - clover-velocity + org.apache.velocity + velocity diff --git a/clover-third-party-library-bom.html b/clover-third-party-library-bom.html index 23a51d54..b0b92cc5 100644 --- a/clover-third-party-library-bom.html +++ b/clover-third-party-library-bom.html @@ -474,15 +474,6 @@

Third party tools (binaries and sources) not bundled in final binaries

www.jetbrains.com target\dependencies\idea used for compilation (in classpath) - - - JARJAR - 1.0rc7, 1.4 - Apache 2.0 - code.google.com/archive/p/jarjar - Maven Central for 1.0.rc7,
- Atlassian Private for 1.4 - see clover-core-libs\jarjar - used for repackaging of third party jars Java Runtime diff --git a/pom.xml b/pom.xml index dee99ae4..fd5b27c6 100644 --- a/pom.xml +++ b/pom.xml @@ -146,8 +146,8 @@ 1.7.36
- org.openclover - clover-velocity + org.apache.velocity + velocity 1.7