This is an automated email from the ASF dual-hosted git repository. sgoeschl pushed a commit to branch FREEMARKER-142 in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git
commit b53fc0b33f8ce4b285c71bb6e8f0df69888aff39 Author: Siegfried Goeschl <[email protected]> AuthorDate: Sat May 30 19:41:41 2020 +0200 FREEMARKER-142 First draft of supporting multiple templates on the command line --- .../generator/base/activation/ByteArrayDataSource.java | 1 - .../generator/base/template/TemplateOutput.java | 16 ++++++++++++++++ .../generator/base/template/TemplateSource.java | 16 ++++++++++++++++ .../generator/base/template/TemplateSourceFactory.java | 18 +++++++++++++++++- .../base/template/TemplateTransformation.java | 16 ++++++++++++++++ .../base/template/TemplateTransformations.java | 16 ++++++++++++++++ .../base/template/TemplateTransformationsBuilder.java | 17 ++++++++++++++++- .../base/template/TemplateTransformationsSupplier.java | 16 ++++++++++++++++ .../freemarker/generator/base/util/MapFlattener.java | 16 ++++++++++++++++ freemarker-generator-base/src/test/data/env/nginx.env | 16 ++++++++++++++++ .../generator/file/RecursiveFileSupplierTest.java | 1 - .../freemarker/generator/util/MapFlattenerTest.java | 16 ++++++++++++++++ .../src/test/template/application.properties | 16 ++++++++++++++++ .../src/test/template/nginx/nginx.conf.ftl | 18 +++++++++++++++++- .../freemarker/generator/cli/config/Settings.java | 7 +------ .../freemarker/generator/cli/config/SettingsTest.java | 2 +- 16 files changed, 196 insertions(+), 12 deletions(-) diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java index 196b254..c5c0a9d 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.freemarker.generator.base.activation; import javax.activation.DataSource; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateOutput.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateOutput.java index e0efc42..782d256 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateOutput.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateOutput.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import org.apache.freemarker.generator.base.util.Validate; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSource.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSource.java index 0659d22..42c36b6 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSource.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSource.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import org.apache.freemarker.generator.base.util.Validate; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSourceFactory.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSourceFactory.java index df3171f..ab53ee3 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSourceFactory.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateSourceFactory.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import org.apache.freemarker.generator.base.datasource.DataSource; @@ -6,7 +22,7 @@ import org.apache.freemarker.generator.base.util.UriUtils; import java.io.File; -public class TemplateSourceFactory { +public abstract class TemplateSourceFactory { public static TemplateSource create(String str) { if (isTemplatePath(str)) { diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformation.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformation.java index 8840e50..b13a799 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformation.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformation.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import static java.util.Objects.requireNonNull; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformations.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformations.java index 380e76a..ed65111 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformations.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformations.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import java.util.ArrayList; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsBuilder.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsBuilder.java index 08c2ae7..37100aa 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsBuilder.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsBuilder.java @@ -1,4 +1,19 @@ -package org.apache.freemarker.generator.base.template; +/* + * 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.generator.base.template; import org.apache.freemarker.generator.base.file.RecursiveFileSupplier; import org.apache.freemarker.generator.base.util.NonClosableWriterWrapper; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsSupplier.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsSupplier.java index d0472b2..ef06672 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsSupplier.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/template/TemplateTransformationsSupplier.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.template; import java.util.function.Supplier; diff --git a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/MapFlattener.java b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/MapFlattener.java index 3800add..80f5dd3 100644 --- a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/MapFlattener.java +++ b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/MapFlattener.java @@ -1,3 +1,19 @@ +/* + * 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.generator.base.util; import java.util.Iterator; diff --git a/freemarker-generator-base/src/test/data/env/nginx.env b/freemarker-generator-base/src/test/data/env/nginx.env index 94973df..111461e 100644 --- a/freemarker-generator-base/src/test/data/env/nginx.env +++ b/freemarker-generator-base/src/test/data/env/nginx.env @@ -1,3 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- NGINX_HOSTNAME=localhost NGINX_WEBROOT=/var/www/project NGINX_LOGS=/var/log/nginx/ \ No newline at end of file diff --git a/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/file/RecursiveFileSupplierTest.java b/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/file/RecursiveFileSupplierTest.java index 5e678c5..06d5d17 100644 --- a/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/file/RecursiveFileSupplierTest.java +++ b/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/file/RecursiveFileSupplierTest.java @@ -105,5 +105,4 @@ public class RecursiveFileSupplierTest { private static RecursiveFileSupplier fileSupplier(List<String> sources, String include, String exclude) { return new RecursiveFileSupplier(sources, singletonList(include), singletonList(exclude)); } - } diff --git a/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/util/MapFlattenerTest.java b/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/util/MapFlattenerTest.java index 882ffe5..92bd90c 100644 --- a/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/util/MapFlattenerTest.java +++ b/freemarker-generator-base/src/test/java/org/apache/freemarker/generator/util/MapFlattenerTest.java @@ -1,3 +1,19 @@ +/* + * 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.generator.util; import org.apache.freemarker.generator.base.util.MapFlattener; diff --git a/freemarker-generator-base/src/test/template/application.properties b/freemarker-generator-base/src/test/template/application.properties index 623dc9c..f4f1c53 100644 --- a/freemarker-generator-base/src/test/template/application.properties +++ b/freemarker-generator-base/src/test/template/application.properties @@ -1,3 +1,19 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- # == application.properties ================================================== server.name=${NGINX_HOSTNAME!"localhost"} server.logs=${NGINX_LOGS!"/var/log/nginx"} diff --git a/freemarker-generator-base/src/test/template/nginx/nginx.conf.ftl b/freemarker-generator-base/src/test/template/nginx/nginx.conf.ftl index dbc6e52..ac57019 100644 --- a/freemarker-generator-base/src/test/template/nginx/nginx.conf.ftl +++ b/freemarker-generator-base/src/test/template/nginx/nginx.conf.ftl @@ -1,7 +1,23 @@ +<#-- + 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. +--> # == nginx-conf ============================================================= server { listen ${NGINX_PORT!"80"}; - server_name ${NGINX_HOSTNAME!"localhost"}; + server_name ${NGINX_HOSTNAME!"somehost"}; root ${NGINX_WEBROOT!"/usr/share/nginx/www"}; index index.htm; diff --git a/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/config/Settings.java b/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/config/Settings.java index c9f2476..89e48bf 100644 --- a/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/config/Settings.java +++ b/freemarker-generator-cli/src/main/java/org/apache/freemarker/generator/cli/config/Settings.java @@ -170,12 +170,7 @@ public class Settings { public List<String> getTemplates() { return templates; } - - // TODO remove later on - public String getTemplateName() { - return templates.isEmpty() ? null : templates.get(0); - } - + public String getInteractiveTemplate() { return interactiveTemplate; } diff --git a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/config/SettingsTest.java b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/config/SettingsTest.java index 4c03542..5aa6681 100644 --- a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/config/SettingsTest.java +++ b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/config/SettingsTest.java @@ -55,7 +55,7 @@ public class SettingsTest { assertEquals(ANY_INPUT_ENCODING, settings.getInputEncoding().name()); assertEquals(ANY_OUTPUT_ENCODING, settings.getOutputEncoding().name()); assertEquals(ANY_OUTPUT_FILE, settings.getOutput().getName()); - assertEquals(ANY_TEMPLATE_NAME, settings.getTemplateName()); + assertEquals(ANY_TEMPLATE_NAME, settings.getTemplates().get(0)); assertNotNull(settings.getDataSources()); assertNotNull(settings.getParameters()); assertNotNull(settings.getSystemProperties());
