[jira] [Comment Edited] (FREEMARKER-54) FM3 freemareker-spring module, basic functionality
[ https://issues.apache.org/jira/browse/FREEMARKER-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053439#comment-16053439 ] Woonsan Ko edited comment on FREEMARKER-54 at 6/19/17 4:54 AM: --- Thanks for the pointer! I've corrected the following: - {{#setSettings(Map)}} was removed as {{#setSetting(Properties)}} is totally fine in spring (ref: bean definition example in commented block in unit test). - Corrected logging in {{SpringResourceTemplateLoader}}. - Added {{VersionEditor}} for Spring because it's more convenient to set by string in XML bean definitions. (See "FooEditor" example in \[1\] for reference.) - Added {{baseLocation}} property in {{SpringResourceTemplateLoader}} for convenience. Since this PR includes {{VersionEditor}} in core, please take a review. Regards, Woonsan \[1\] https://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#beans-beans-conversion was (Author: woon_san): Thanks for the pointer! I've corrected the following: - {{#setSettings(Map)}} was removed as {{#setSetting(Properties)}} is totally fine in spring (ref: bean definition example in commented block in unit test). - Corrected logging in {{SpringResourceTemplateLoader}}. - Added {{VersionEditor}} for Spring because it's more convenient to set by string in XML bean definitions. (See "FooEditor" example in \[1\] for reference.) Since this PR includes {{VersionEditor}} in core, please take a review. Regards, Woonsan \[1\] https://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#beans-beans-conversion > FM3 freemareker-spring module, basic functionality > -- > > Key: FREEMARKER-54 > URL: https://issues.apache.org/jira/browse/FREEMARKER-54 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Create the Gradle module. Basic non-Web functionality. This certainly means: > * Creating a FactoryBean by extending {{Configuration.ExtendableBuilder}} > which has defaults that are practical for Spring. > * Creating a {{SpringResourceTemplateLoader}} which relies on Spring's > {{Resource}} abstraction > It's also an important goal to polish the {{freemarker-core}} configuration > and template loader API-s, and change them if that's needed for smoother > Spring integration. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FREEMARKER-54) FM3 freemareker-spring module, basic functionality
[ https://issues.apache.org/jira/browse/FREEMARKER-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053439#comment-16053439 ] Woonsan Ko commented on FREEMARKER-54: -- Thanks for the pointer! I've corrected the following: - {{#setSettings(Map)}} was removed as {{#setSetting(Properties)}} is totally fine in spring (ref: bean definition example in commented block in unit test). - Corrected logging in {{SpringResourceTemplateLoader}}. - Added {{VersionEditor}} for Spring because it's more convenient to set by string in XML bean definitions. (See "FooEditor" example in \[1\] for reference.) Since this PR includes {{VersionEditor}} in core, please take a review. Regards, Woonsan \[1\] https://docs.spring.io/spring/docs/current/spring-framework-reference/html/validation.html#beans-beans-conversion > FM3 freemareker-spring module, basic functionality > -- > > Key: FREEMARKER-54 > URL: https://issues.apache.org/jira/browse/FREEMARKER-54 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Create the Gradle module. Basic non-Web functionality. This certainly means: > * Creating a FactoryBean by extending {{Configuration.ExtendableBuilder}} > which has defaults that are practical for Spring. > * Creating a {{SpringResourceTemplateLoader}} which relies on Spring's > {{Resource}} abstraction > It's also an important goal to polish the {{freemarker-core}} configuration > and template loader API-s, and change them if that's needed for smoother > Spring integration. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (FREEMARKER-54) FM3 freemareker-spring module, basic functionality
[ https://issues.apache.org/jira/browse/FREEMARKER-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053436#comment-16053436 ] ASF GitHub Bot commented on FREEMARKER-54: -- GitHub user woonsan opened a pull request: https://github.com/apache/incubator-freemarker/pull/24 FREEMARKER-54: Remove unnecessary #setSettings(); Logging correction; VersionEditor for conversion between string and Version You can merge this pull request into a Git repository by running: $ git pull https://github.com/woonsan/incubator-freemarker feature/FREEMARKER-54 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-freemarker/pull/24.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #24 commit 94828521fc30f0d51c7728d37b537404c8096bfe Author: Woonsan Ko Date: 2017-06-19T02:12:03Z FREEMARKER-54: Remove ConfigurationFactoryBean#setSettings(...) because ancestor already contains equivalent one. Also, separate spring logger. commit cb43725a79e851c11d4552d3a5ab0b6d70d43e9d Author: Woonsan Ko Date: 2017-06-19T03:13:56Z FREEMARKER-54: Support Version convertion editor between string and Version object for spring community > FM3 freemareker-spring module, basic functionality > -- > > Key: FREEMARKER-54 > URL: https://issues.apache.org/jira/browse/FREEMARKER-54 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Create the Gradle module. Basic non-Web functionality. This certainly means: > * Creating a FactoryBean by extending {{Configuration.ExtendableBuilder}} > which has defaults that are practical for Spring. > * Creating a {{SpringResourceTemplateLoader}} which relies on Spring's > {{Resource}} abstraction > It's also an important goal to polish the {{freemarker-core}} configuration > and template loader API-s, and change them if that's needed for smoother > Spring integration. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[GitHub] incubator-freemarker pull request #24: FREEMARKER-54: Remove unnecessary #se...
GitHub user woonsan opened a pull request: https://github.com/apache/incubator-freemarker/pull/24 FREEMARKER-54: Remove unnecessary #setSettings(); Logging correction; VersionEditor for conversion between string and Version You can merge this pull request into a Git repository by running: $ git pull https://github.com/woonsan/incubator-freemarker feature/FREEMARKER-54 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/incubator-freemarker/pull/24.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #24 commit 94828521fc30f0d51c7728d37b537404c8096bfe Author: Woonsan Ko Date: 2017-06-19T02:12:03Z FREEMARKER-54: Remove ConfigurationFactoryBean#setSettings(...) because ancestor already contains equivalent one. Also, separate spring logger. commit cb43725a79e851c11d4552d3a5ab0b6d70d43e9d Author: Woonsan Ko Date: 2017-06-19T03:13:56Z FREEMARKER-54: Support Version convertion editor between string and Version object for spring community --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[jira] [Commented] (FREEMARKER-54) FM3 freemareker-spring module, basic functionality
[ https://issues.apache.org/jira/browse/FREEMARKER-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053218#comment-16053218 ] Daniel Dekany commented on FREEMARKER-54: - As of {{ConfigurationFactoryBean.setSettings(Map)}}, {{ExtendedBuilder}} already has a very similar method inherited: {{org.apache.freemarker.core.MutableProcessingConfiguration.setSettings(Properties)}}. If a {{Map}} parameter is better than a {{Properties}}, then I think you should change {{MutableProcessingConfiguration.setSettings}} (with considering that Bean property setters can't be overloaded, and {{Properties}} extends {{Map}}, not {{Map}}... so it will be a bit ugly, and {{_CollectionUtil.safeCastMap}} will be needed). > FM3 freemareker-spring module, basic functionality > -- > > Key: FREEMARKER-54 > URL: https://issues.apache.org/jira/browse/FREEMARKER-54 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Create the Gradle module. Basic non-Web functionality. This certainly means: > * Creating a FactoryBean by extending {{Configuration.ExtendableBuilder}} > which has defaults that are practical for Spring. > * Creating a {{SpringResourceTemplateLoader}} which relies on Spring's > {{Resource}} abstraction > It's also an important goal to polish the {{freemarker-core}} configuration > and template loader API-s, and change them if that's needed for smoother > Spring integration. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[1/9] incubator-freemarker git commit: FREEMARKER-54: Adding skeletal freemarker-spring module
Repository: incubator-freemarker Updated Branches: refs/heads/3 c73dc5678 -> 1988dc0c8 FREEMARKER-54: Adding skeletal freemarker-spring module Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/dbbfe990 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/dbbfe990 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/dbbfe990 Branch: refs/heads/3 Commit: dbbfe99074d22fa59437a6d90499f3f3199040ba Parents: e78181a Author: Woonsan Ko Authored: Wed Jun 14 21:03:35 2017 -0400 Committer: Woonsan Ko Committed: Wed Jun 14 21:03:35 2017 -0400 -- freemarker-spring/build.gradle | 102 +++ .../spring/SpringConfigurationBuilder.java | 30 ++ settings.gradle | 1 + 3 files changed, 133 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/dbbfe990/freemarker-spring/build.gradle -- diff --git a/freemarker-spring/build.gradle b/freemarker-spring/build.gradle new file mode 100644 index 000..fa32eac --- /dev/null +++ b/freemarker-spring/build.gradle @@ -0,0 +1,102 @@ +/* + * 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. + */ + +title = "Apache FreeMarker Spring Framework support" +description = """\ +FreeMarker template engine, Spring Framework support. \ +This is an optional module, mostly useful in frameworks based on Spring Framework.""" + +dependencies { +compile project(":freemarker-core") + +compileOnly "javax.servlet:servlet-api:2.5" + +def springVersion = "4.3.9.RELEASE" + +compileOnly("org.springframework:spring-core:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +compileOnly("org.springframework:spring-beans:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +compileOnly("org.springframework:spring-context:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +compileOnly("org.springframework:spring-context-support:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +compileOnly("org.springframework:spring-web:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +compileOnly("org.springframework:spring-webmvc:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} + +// +// For tests + +testCompile("org.springframework:spring-test:$springVersion") { +exclude group: "commons-logging", module: "commons-logging" +} +} + +jar { +manifest { +// This is needed for "a.class.from.another.Bundle"?new() to work. +instructionReplace 'DynamicImport-Package', '*' + +instructionReplace 'Bundle-RequiredExecutionEnvironment', 'JavaSE-1.7' +// TODO Gradle adds a "Require-Capability"... is it a problem? If not, do we need the above? + +attributes( +"Extension-name": "${project.group}:${project.name}", +"Specification-Title": project.title, +"Implementation-Title": project.title +) +} +} + +javadoc { +title "${project.title} ${versionCanonical} API" +} + +// The identical parts of Maven "deployer" and "installer" configurations: +def mavenCommons = { callerDelegate -> +delegate = callerDelegate + +pom.project { +description project.description +} +} + +uploadArchives { +repositories { +mavenDeployer { +mavenCommons(delegate) +} +} +} + +install { +repositories { +mavenInstaller { +mavenCommons(delegate) +} +} +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/dbbfe990/freemarker-spring/src/main/java/org/apache/freemarker/spring/SpringConf
[jira] [Commented] (FREEMARKER-54) FM3 freemareker-spring module, basic functionality
[ https://issues.apache.org/jira/browse/FREEMARKER-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16053213#comment-16053213 ] ASF GitHub Bot commented on FREEMARKER-54: -- Github user asfgit closed the pull request at: https://github.com/apache/incubator-freemarker/pull/23 > FM3 freemareker-spring module, basic functionality > -- > > Key: FREEMARKER-54 > URL: https://issues.apache.org/jira/browse/FREEMARKER-54 > Project: Apache Freemarker > Issue Type: Task >Affects Versions: 3.0.0 >Reporter: Daniel Dekany > > Create the Gradle module. Basic non-Web functionality. This certainly means: > * Creating a FactoryBean by extending {{Configuration.ExtendableBuilder}} > which has defaults that are practical for Spring. > * Creating a {{SpringResourceTemplateLoader}} which relies on Spring's > {{Resource}} abstraction > It's also an important goal to polish the {{freemarker-core}} configuration > and template loader API-s, and change them if that's needed for smoother > Spring integration. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[3/9] incubator-freemarker git commit: feature/FREEMARKER-54: ConfigurationFactoryBean tests
feature/FREEMARKER-54: ConfigurationFactoryBean tests Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/2783387e Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/2783387e Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/2783387e Branch: refs/heads/3 Commit: 2783387eb495331042e72449f02b2a18527a9e13 Parents: 57270ec Author: Woonsan Ko Authored: Thu Jun 15 00:37:24 2017 -0400 Committer: Woonsan Ko Committed: Thu Jun 15 00:37:24 2017 -0400 -- .../freemarker/spring/ConfigurationFactoryBean.java | 2 ++ .../freemarker/spring/ConfigurationFactoryBeanTest.java | 12 2 files changed, 14 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/2783387e/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java -- diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java index ead823d..2761b9a 100644 --- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java +++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java @@ -44,6 +44,8 @@ public class ConfigurationFactoryBean extends ExtendableBuilder settings = new LinkedHashMap<>(); public ConfigurationFactoryBean() { +// By default, set the default version constant. +// #setIncompatibleImprovements(Version) can be used to change it. super(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS); delegate = new AbstractFactoryBean() { http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/2783387e/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java -- diff --git a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java index 7dcbcc5..82a5e74 100644 --- a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java +++ b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java @@ -18,13 +18,16 @@ */ package org.apache.freemarker.spring; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Configuration.ExtendableBuilder; +import org.apache.freemarker.core.Version; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -55,9 +58,15 @@ public class ConfigurationFactoryBeanTest { final Map settings = new LinkedHashMap<>(); settings.put(ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE, "true"); +final Map sharedVars = new HashMap<>(); +sharedVars.put("sharedVar1", "sharedVal1"); +sharedVars.put("sharedVar2", "sharedVal2"); + BeanDefinition beanDef = BeanDefinitionBuilder.genericBeanDefinition(ConfigurationFactoryBean.class.getName()) +.addPropertyValue("incompatibleImprovements", new Version(3, 0, 0)) .addPropertyValue("settings", settings) +.addPropertyValue("sharedVariables", sharedVars) .getBeanDefinition(); appContext.registerBeanDefinition("freemarkerConfig", beanDef); @@ -68,7 +77,10 @@ public class ConfigurationFactoryBeanTest { assertTrue("Not a Configuration object: " + bean, bean instanceof Configuration); Configuration config = (Configuration) bean; +assertEquals(new Version(3, 0, 0), config.getIncompatibleImprovements()); assertTrue(config.getLocalizedTemplateLookup()); +assertEquals("sharedVal1", config.getSharedVariables().get("sharedVar1")); +assertEquals("sharedVal2", config.getSharedVariables().get("sharedVar2")); } }
[8/9] incubator-freemarker git commit: freemareker-spring module, basic functionality
freemareker-spring module, basic functionality Merge commit 'refs/pull/23/head' of https://github.com/apache/incubator-freemarker into 3 Conflicts: settings.gradle Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/886fd666 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/886fd666 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/886fd666 Branch: refs/heads/3 Commit: 886fd66684d06d161dbc1b139eb1a35f01030420 Parents: c73dc56 fc1f429 Author: ddekany Authored: Sun Jun 18 16:26:51 2017 +0200 Committer: ddekany Committed: Sun Jun 18 16:26:51 2017 +0200 -- freemarker-spring/build.gradle | 99 +++ .../spring/ConfigurationFactoryBean.java| 118 + .../SpringResourceTemplateLoader.java | 123 ++ .../spring/ConfigurationFactoryBeanTest.java| 127 +++ .../SpringResourceTemplateLoaderTest.java | 82 .../META-INF/templates/sub1/sub2/t.ftl | 1 + settings.gradle | 2 +- 7 files changed, 551 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/886fd666/settings.gradle -- diff --cc settings.gradle index 1f07da1,2373331..f8f9b47 --- a/settings.gradle +++ b/settings.gradle @@@ -26,5 -26,5 +26,5 @@@ include 'freemarker-servlet include 'freemarker-test-utils' include 'freemarker-manual' include 'freemarker-dom' + include 'freemarker-spring' - +include 'freemarker-converter' -
[2/9] incubator-freemarker git commit: FREEMARKER-54: initial ConfigurationFactoryBean design
FREEMARKER-54: initial ConfigurationFactoryBean design Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/57270ecf Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/57270ecf Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/57270ecf Branch: refs/heads/3 Commit: 57270ecf85744c5c6ca566c89f21f721a7a9d59a Parents: dbbfe99 Author: Woonsan Ko Authored: Thu Jun 15 00:10:58 2017 -0400 Committer: Woonsan Ko Committed: Thu Jun 15 00:10:58 2017 -0400 -- freemarker-spring/build.gradle | 13 +-- .../spring/ConfigurationFactoryBean.java| 115 +++ .../spring/SpringConfigurationBuilder.java | 30 - .../spring/ConfigurationFactoryBeanTest.java| 74 4 files changed, 194 insertions(+), 38 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/57270ecf/freemarker-spring/build.gradle -- diff --git a/freemarker-spring/build.gradle b/freemarker-spring/build.gradle index fa32eac..d5f7e15 100644 --- a/freemarker-spring/build.gradle +++ b/freemarker-spring/build.gradle @@ -29,22 +29,19 @@ dependencies { def springVersion = "4.3.9.RELEASE" -compileOnly("org.springframework:spring-core:$springVersion") { +compile("org.springframework:spring-core:$springVersion") { exclude group: "commons-logging", module: "commons-logging" } -compileOnly("org.springframework:spring-beans:$springVersion") { +compile("org.springframework:spring-beans:$springVersion") { exclude group: "commons-logging", module: "commons-logging" } -compileOnly("org.springframework:spring-context:$springVersion") { +compile("org.springframework:spring-context:$springVersion") { exclude group: "commons-logging", module: "commons-logging" } -compileOnly("org.springframework:spring-context-support:$springVersion") { +compile("org.springframework:spring-web:$springVersion") { exclude group: "commons-logging", module: "commons-logging" } -compileOnly("org.springframework:spring-web:$springVersion") { -exclude group: "commons-logging", module: "commons-logging" -} -compileOnly("org.springframework:spring-webmvc:$springVersion") { +compile("org.springframework:spring-webmvc:$springVersion") { exclude group: "commons-logging", module: "commons-logging" } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/57270ecf/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java -- diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java new file mode 100644 index 000..ead823d --- /dev/null +++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java @@ -0,0 +1,115 @@ +/* + * 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. + */ +package org.apache.freemarker.spring; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.apache.freemarker.core.Configuration; +import org.apache.freemarker.core.Configuration.ExtendableBuilder; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.BeanClassLoaderAware; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.config.AbstractFactoryBean; + +/** + * Configuration factory bean to support Spring Framework applications. + */ +public class ConfigurationFactoryBean extends Ext
[4/9] incubator-freemarker git commit: FREEMARKER-54: More setting tests through ConfigurationFactoryBean
FREEMARKER-54: More setting tests through ConfigurationFactoryBean Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/99c3c0cb Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/99c3c0cb Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/99c3c0cb Branch: refs/heads/3 Commit: 99c3c0cb45cf500a0fc914332a88f78e17c9d5e6 Parents: 2783387 Author: Woonsan Ko Authored: Thu Jun 15 23:15:08 2017 -0400 Committer: Woonsan Ko Committed: Thu Jun 15 23:15:08 2017 -0400 -- .../spring/ConfigurationFactoryBean.java| 1 + .../spring/ConfigurationFactoryBeanTest.java| 46 ++-- 2 files changed, 44 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/99c3c0cb/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java -- diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java index 2761b9a..da275e7 100644 --- a/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java +++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/ConfigurationFactoryBean.java @@ -72,6 +72,7 @@ public class ConfigurationFactoryBean extends ExtendableBuilder settings) { +this.settings.clear(); this.settings.putAll(settings); } http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/99c3c0cb/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java -- diff --git a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java index 82a5e74..59261aa 100644 --- a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java +++ b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java @@ -19,15 +19,25 @@ package org.apache.freemarker.spring; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import java.nio.charset.Charset; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import org.apache.freemarker.core.AutoEscapingPolicy; import org.apache.freemarker.core.Configuration; import org.apache.freemarker.core.Configuration.ExtendableBuilder; +import org.apache.freemarker.core.MutableParsingAndProcessingConfiguration; +import org.apache.freemarker.core.NamingConvention; +import org.apache.freemarker.core.TagSyntax; +import org.apache.freemarker.core.TemplateLanguage; import org.apache.freemarker.core.Version; +import org.apache.freemarker.core.model.impl.RestrictedObjectWrapper; +import org.apache.freemarker.core.templateresolver.CacheStorage; +import org.apache.freemarker.core.templateresolver.impl.MruCacheStorage; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -54,9 +64,22 @@ public class ConfigurationFactoryBeanTest { } @Test -public void testConfigurationFactoryBeanDefinition() throws Exception { +public void testConfigurationFactoryBeanSettings() throws Exception { final Map settings = new LinkedHashMap<>(); - settings.put(ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY_CAMEL_CASE, "true"); + + settings.put(MutableParsingAndProcessingConfiguration.SOURCE_ENCODING_KEY, "UTF-8"); + settings.put(MutableParsingAndProcessingConfiguration.WHITESPACE_STRIPPING_KEY, "true"); + settings.put(MutableParsingAndProcessingConfiguration.AUTO_ESCAPING_POLICY_KEY, "enableIfSupported"); + settings.put(MutableParsingAndProcessingConfiguration.RECOGNIZE_STANDARD_FILE_EXTENSIONS_KEY, "true"); + settings.put(MutableParsingAndProcessingConfiguration.TEMPLATE_LANGUAGE_KEY, "FTL"); +settings.put(MutableParsingAndProcessingConfiguration.TAG_SYNTAX_KEY, "squareBracket"); + settings.put(MutableParsingAndProcessingConfiguration.NAMING_CONVENTION_KEY, "camelCase"); +settings.put(MutableParsingAndProcessingConfiguration.TAB_SIZE_KEY, "4"); + +settings.put(ExtendableBuilder.OBJECT_WRAPPER_KEY, "restricted"); +settings.put(ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY, "false"); +settings.put(ExtendableBuilder.TEMPLATE_CACHE_STORAGE_KEY, "strong:20, soft:250"); +settings.put(ExtendableBuilder.TEMPLATE_UPDATE_DELAY_
[GitHub] incubator-freemarker pull request #23: FREEMARKER-54: FM3 freemareker-spring...
Github user asfgit closed the pull request at: https://github.com/apache/incubator-freemarker/pull/23 --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---
[5/9] incubator-freemarker git commit: FREEMARKER-54: use property wherever easier than settings map.
FREEMARKER-54: use property wherever easier than settings map. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/18ee8a08 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/18ee8a08 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/18ee8a08 Branch: refs/heads/3 Commit: 18ee8a0846dbbbf4b853af8f76509f331bfb07ae Parents: 99c3c0c Author: Woonsan Ko Authored: Thu Jun 15 23:23:42 2017 -0400 Committer: Woonsan Ko Committed: Thu Jun 15 23:23:42 2017 -0400 -- .../apache/freemarker/spring/ConfigurationFactoryBeanTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/18ee8a08/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java -- diff --git a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java index 59261aa..0938f5b 100644 --- a/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java +++ b/freemarker-spring/src/test/java/org/apache/freemarker/spring/ConfigurationFactoryBeanTest.java @@ -77,19 +77,20 @@ public class ConfigurationFactoryBeanTest { settings.put(MutableParsingAndProcessingConfiguration.TAB_SIZE_KEY, "4"); settings.put(ExtendableBuilder.OBJECT_WRAPPER_KEY, "restricted"); -settings.put(ExtendableBuilder.LOCALIZED_TEMPLATE_LOOKUP_KEY, "false"); settings.put(ExtendableBuilder.TEMPLATE_CACHE_STORAGE_KEY, "strong:20, soft:250"); -settings.put(ExtendableBuilder.TEMPLATE_UPDATE_DELAY_KEY, "1m"); final Map sharedVars = new HashMap<>(); sharedVars.put("sharedVar1", "sharedVal1"); sharedVars.put("sharedVar2", "sharedVal2"); +// Creating bean definition which is equivalent to element in Spring XML configuration. BeanDefinition beanDef = BeanDefinitionBuilder.genericBeanDefinition(ConfigurationFactoryBean.class.getName()) .addPropertyValue("incompatibleImprovements", new Version(3, 0, 0)) .addPropertyValue("settings", settings) .addPropertyValue("sharedVariables", sharedVars) +.addPropertyValue("templateUpdateDelayMilliseconds", 6) +.addPropertyValue("localizedTemplateLookup", "false") .getBeanDefinition(); appContext.registerBeanDefinition("freemarkerConfig", beanDef);
[6/9] incubator-freemarker git commit: FREEMARKER-54: Adding SpringResourceTemplateLoader and test
FREEMARKER-54: Adding SpringResourceTemplateLoader and test Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/a571c24f Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/a571c24f Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/a571c24f Branch: refs/heads/3 Commit: a571c24f6fc9544e164eeaf71347044b3fe88182 Parents: 18ee8a0 Author: Woonsan Ko Authored: Sat Jun 17 23:44:46 2017 -0400 Committer: Woonsan Ko Committed: Sat Jun 17 23:44:46 2017 -0400 -- .../SpringResourceTemplateLoader.java | 123 +++ .../SpringResourceTemplateLoaderTest.java | 82 + .../META-INF/templates/sub1/sub2/t.ftl | 1 + 3 files changed, 206 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/a571c24f/freemarker-spring/src/main/java/org/apache/freemarker/spring/templateresolver/SpringResourceTemplateLoader.java -- diff --git a/freemarker-spring/src/main/java/org/apache/freemarker/spring/templateresolver/SpringResourceTemplateLoader.java b/freemarker-spring/src/main/java/org/apache/freemarker/spring/templateresolver/SpringResourceTemplateLoader.java new file mode 100644 index 000..a327bab --- /dev/null +++ b/freemarker-spring/src/main/java/org/apache/freemarker/spring/templateresolver/SpringResourceTemplateLoader.java @@ -0,0 +1,123 @@ +/* + * 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. + */ +package org.apache.freemarker.spring.templateresolver; + +import java.io.IOException; +import java.io.Serializable; +import java.util.Objects; + +import org.apache.freemarker.core._CoreLogs; +import org.apache.freemarker.core.templateresolver.TemplateLoader; +import org.apache.freemarker.core.templateresolver.TemplateLoaderSession; +import org.apache.freemarker.core.templateresolver.TemplateLoadingResult; +import org.apache.freemarker.core.templateresolver.TemplateLoadingSource; +import org.slf4j.Logger; +import org.springframework.context.ResourceLoaderAware; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; + +/** + * A {@link TemplateLoader} that uses Spring Framework Resources which are resolved by locations. + */ +public class SpringResourceTemplateLoader implements TemplateLoader, ResourceLoaderAware { + +private static final Logger LOG = _CoreLogs.TEMPLATE_RESOLVER; + +private ResourceLoader resourceLoader; + +@Override +public void setResourceLoader(ResourceLoader resourceLoader) { +this.resourceLoader = resourceLoader; +} + +@Override +public TemplateLoaderSession createSession() { +return null; +} + +@Override +public TemplateLoadingResult load(String name, TemplateLoadingSource ifSourceDiffersFrom, +Serializable ifVersionDiffersFrom, TemplateLoaderSession session) throws IOException { +if (resourceLoader == null) { +throw new IllegalStateException("Spring Framework ResourceLoader was not set."); +} + +Resource resource = resourceLoader.getResource(name); + +if (!resource.exists()) { +return TemplateLoadingResult.NOT_FOUND; +} + +ResourceTemplateLoadingSource source = new ResourceTemplateLoadingSource(resource); + +Long version = null; + +try { +long lmd = resource.lastModified(); +if (lmd != -1) { +version = lmd; +} +} catch (IOException e) { +if (LOG.isDebugEnabled()) { +LOG.debug("The last modified timestamp of the resource at '{}' may not be resolved. {}", name, +e.toString()); +} +} + +if (ifSourceDiffersFrom != null && ifSourceDiffersFrom.equals(source) +&& Objects.equals(ifVersionDiffersFrom, version)) { +return TemplateLoadingResult.NOT_MODIFIED; +} + +
[7/9] incubator-freemarker git commit: Merge branch '3' into feature/FREEMARKER-54
Merge branch '3' into feature/FREEMARKER-54 Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/fc1f429c Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/fc1f429c Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/fc1f429c Branch: refs/heads/3 Commit: fc1f429cc4174b8ced71617074718715b81ee575 Parents: a571c24 cb4a93d Author: Woonsan Ko Authored: Sat Jun 17 23:45:59 2017 -0400 Committer: Woonsan Ko Committed: Sat Jun 17 23:45:59 2017 -0400 -- build.gradle| 7 +- .../org/apache/freemarker/core/ASTPrinter.java | 2 +- .../org/apache/freemarker/core/ast-1.ast| 2 +- .../org/apache/freemarker/core/ast-range.ast| 26 ++-- .../org/apache/freemarker/core/ASTComment.java | 2 +- .../apache/freemarker/core/ASTDebugBreak.java | 2 +- .../freemarker/core/ASTDirAssignment.java | 24 ++-- .../core/ASTDirAssignmentsContainer.java| 2 +- .../core/ASTDirAttemptRecoverContainer.java | 8 +- .../apache/freemarker/core/ASTDirAutoEsc.java | 6 +- .../org/apache/freemarker/core/ASTDirBreak.java | 4 +- .../core/ASTDirCapturingAssignment.java | 6 +- .../org/apache/freemarker/core/ASTDirCase.java | 4 +- .../apache/freemarker/core/ASTDirCompress.java | 6 +- .../freemarker/core/ASTDirElseOfList.java | 6 +- .../apache/freemarker/core/ASTDirEscape.java| 6 +- .../apache/freemarker/core/ASTDirFallback.java | 4 +- .../org/apache/freemarker/core/ASTDirFlush.java | 4 +- .../core/ASTDirIfElseIfElseContainer.java | 4 +- .../freemarker/core/ASTDirIfOrElseOrElseIf.java | 4 +- .../apache/freemarker/core/ASTDirImport.java| 4 +- .../apache/freemarker/core/ASTDirInclude.java | 4 +- .../org/apache/freemarker/core/ASTDirItems.java | 8 +- .../org/apache/freemarker/core/ASTDirList.java | 6 +- .../core/ASTDirListElseContainer.java | 4 +- .../org/apache/freemarker/core/ASTDirMacro.java | 6 +- .../apache/freemarker/core/ASTDirNested.java| 4 +- .../apache/freemarker/core/ASTDirNoAutoEsc.java | 6 +- .../apache/freemarker/core/ASTDirNoEscape.java | 8 +- .../freemarker/core/ASTDirOutputFormat.java | 8 +- .../apache/freemarker/core/ASTDirRecover.java | 6 +- .../apache/freemarker/core/ASTDirRecurse.java | 4 +- .../apache/freemarker/core/ASTDirReturn.java| 4 +- .../org/apache/freemarker/core/ASTDirSep.java | 8 +- .../apache/freemarker/core/ASTDirSetting.java | 4 +- .../org/apache/freemarker/core/ASTDirStop.java | 4 +- .../apache/freemarker/core/ASTDirSwitch.java| 6 +- .../apache/freemarker/core/ASTDirTOrTrOrTl.java | 4 +- .../freemarker/core/ASTDirUserDefined.java | 2 +- .../org/apache/freemarker/core/ASTDirVisit.java | 4 +- .../freemarker/core/ASTDollarInterpolation.java | 2 +- .../org/apache/freemarker/core/ASTElement.java | 2 +- .../freemarker/core/ASTExpAddOrConcat.java | 2 +- .../org/apache/freemarker/core/ASTExpAnd.java | 2 +- .../freemarker/core/ASTExpArithmetic.java | 129 +++ .../freemarker/core/ASTExpBooleanLiteral.java | 2 +- .../apache/freemarker/core/ASTExpBuiltIn.java | 2 +- .../freemarker/core/ASTExpBuiltInVariable.java | 2 +- .../freemarker/core/ASTExpComparison.java | 2 +- .../apache/freemarker/core/ASTExpDefault.java | 2 +- .../org/apache/freemarker/core/ASTExpDot.java | 4 +- .../freemarker/core/ASTExpDynamicKeyName.java | 2 +- .../apache/freemarker/core/ASTExpExists.java| 4 +- .../freemarker/core/ASTExpHashLiteral.java | 2 +- .../freemarker/core/ASTExpListLiteral.java | 2 +- .../freemarker/core/ASTExpMethodCall.java | 2 +- .../freemarker/core/ASTExpNegateOrPlus.java | 2 +- .../org/apache/freemarker/core/ASTExpNot.java | 2 +- .../freemarker/core/ASTExpNumberLiteral.java| 2 +- .../org/apache/freemarker/core/ASTExpOr.java| 2 +- .../freemarker/core/ASTExpParenthesis.java | 2 +- .../org/apache/freemarker/core/ASTExpRange.java | 4 +- .../freemarker/core/ASTExpStringLiteral.java| 2 +- .../apache/freemarker/core/ASTExpVariable.java | 2 +- .../freemarker/core/ASTHashInterpolation.java | 2 +- .../freemarker/core/ASTImplicitParent.java | 4 +- .../org/apache/freemarker/core/ASTNode.java | 9 +- .../apache/freemarker/core/ASTStaticText.java | 2 +- .../freemarker/core/ArithmeticExpression.java | 129 --- .../core/BuiltInWithParseTimeParameters.java| 4 +- .../freemarker/core/ParsingConfiguration.java | 5 +- ...nterruptionSupportTemplatePostProcessor.java | 4 +- .../core/_ErrorDescriptionBuilder.java | 2 +- freemarker-core/src/main/javacc/FTL.jj | 12 +- freemarke
[9/9] incubator-freemarker git commit: Fixed JavaDoc error in freemarker-converter
Fixed JavaDoc error in freemarker-converter Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/1988dc0c Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/1988dc0c Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/1988dc0c Branch: refs/heads/3 Commit: 1988dc0c88931757ccc7d82b2f711fe67b958090 Parents: 886fd66 Author: ddekany Authored: Sun Jun 18 16:30:14 2017 +0200 Committer: ddekany Committed: Sun Jun 18 16:30:14 2017 +0200 -- .../src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/1988dc0c/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java -- diff --git a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java index 0c95e1d..6afcfa1 100644 --- a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java +++ b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java @@ -42,7 +42,8 @@ import freemarker.template.Template; * the insignificant white-space and comments inside the tags is even trickier. * This information has to be restored from the source code string ({@link #src}), based on the positions (begin/end * column/row number) of the AST nodes, and sometimes that has to be combined with some simple manual parsing. - * Do not hard-code "<" and ">" into the code where you should use {@link #tagBeginChar} and {@link #tagEndChar}. + * Do not hard-code "<" and ">" into the code where you should use {@link #tagBeginChar} and + * {@link #tagEndChar}. * Stopping with error is always better than risking incorrect output. Use assertions. Don't be permissive with * unexpected input. * Generally, try to use node parameters (via {@link #getOnlyParam(TemplateObject, ParameterRole, Class)},
incubator-freemarker git commit: Started working in freemarker-converter, which converts FM2 templates to FM3 syntax (as far as it can be automated). It's not working yet, very far from complete. We w
Repository: incubator-freemarker Updated Branches: refs/heads/3 cb4a93dc2 -> c73dc5678 Started working in freemarker-converter, which converts FM2 templates to FM3 syntax (as far as it can be automated). It's not working yet, very far from complete. We will need this before we start to change the syntax, as we have a lot of test templates. Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/c73dc567 Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/c73dc567 Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/c73dc567 Branch: refs/heads/3 Commit: c73dc567834059e710bed252253d4a0b7b6568c0 Parents: cb4a93d Author: ddekany Authored: Sun Jun 18 16:20:12 2017 +0200 Committer: ddekany Committed: Sun Jun 18 16:20:12 2017 +0200 -- freemarker-converter/build.gradle | 72 +++ .../core/FM2ASTToFM3SourceConverter.java| 500 +++ .../core/UnexpectedNodeContentException.java| 41 ++ .../apache/freemarker/converter/Converter.java | 273 ++ .../converter/ConverterException.java | 32 ++ .../freemarker/converter/ConverterUtils.java| 55 ++ .../freemarker/converter/FM2ToFM3Converter.java | 133 + .../MissingRequiredPropertyException.java | 34 ++ .../converter/PropertyValidationException.java | 51 ++ .../freemarker/converter/ConverterUtilTest.java | 42 ++ .../converter/FM2ToFM3ConverterTest.java| 173 +++ .../converter/GenericConverterTest.java | 180 +++ .../converter/test/ConverterTest.java | 46 ++ settings.gradle | 1 + 14 files changed, 1633 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c73dc567/freemarker-converter/build.gradle -- diff --git a/freemarker-converter/build.gradle b/freemarker-converter/build.gradle new file mode 100644 index 000..04254f7 --- /dev/null +++ b/freemarker-converter/build.gradle @@ -0,0 +1,72 @@ +/* + * 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. + */ + +title = "Apache FreeMarker Converter" +description = """\ +FreeMarker template converter tool. Used to convert between template languages.""" + +dependencies { +compile project(":freemarker-core") +compile "org.freemarker:freemarker:2.3.26-incubating" +compile libraries.commonsCli +compile libraries.commonsLang +compile libraries.commonsIo +compile libraries.guava +} + +jar { +manifest { +instructionReplace 'Bundle-RequiredExecutionEnvironment', 'JavaSE-1.7' + +attributes( +"Extension-name": "${project.group}:${project.name}", +"Specification-Title": project.title, +"Implementation-Title": project.title +) +} +} + +javadoc { +title "${project.title} ${versionCanonical} API" +} + +// The identical parts of Maven "deployer" and "installer" configurations: +def mavenCommons = { callerDelegate -> +delegate = callerDelegate + +pom.project { +description project.description +} +} + +uploadArchives { +repositories { +mavenDeployer { +mavenCommons(delegate) +} +} +} + +install { +repositories { +mavenInstaller { +mavenCommons(delegate) +} +} +} http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/c73dc567/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java -- diff --git a/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java new file mode 100644 index 000..0c95e1d --- /dev/null +++ b/freemarker-converter/src/main/java/freemarker/core/FM2ASTToFM3SourceConverter.java @@ -0,0 +1,500 @@ +/* + * Licensed to the Apache Software Foundation (AS