You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by sg...@apache.org on 2020/02/04 20:43:24 UTC

[freemarker-generator] branch FREEMARKER-129 updated: FREEMARKER-129 Extract submodule "freemarker-generator-base"

This is an automated email from the ASF dual-hosted git repository.

sgoeschl pushed a commit to branch FREEMARKER-129
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git


The following commit(s) were added to refs/heads/FREEMARKER-129 by this push:
     new aea5403  FREEMARKER-129 Extract submodule "freemarker-generator-base"
aea5403 is described below

commit aea5403bd1265a32f6cf8849621da37b08ae1bf5
Author: Siegfried Goeschl <si...@gmail.com>
AuthorDate: Tue Feb 4 21:43:09 2020 +0100

    FREEMARKER-129 Extract submodule "freemarker-generator-base"
---
 base/LICENSE                                       | 201 +++++++++++++++++++++
 base/pom.xml                                       |  53 ++++++
 .../base/activation/ByteArrayDataSource.java       |  32 ++--
 .../base}/activation/InputStreamDataSource.java    |   2 +-
 .../base}/activation/StringDataSource.java         |   4 +-
 .../base/config}/RecursiveFileResolver.java        |  37 ++--
 .../generator/base/document}/Document.java         |  17 +-
 .../generator/base/document}/DocumentFactory.java  |  22 ++-
 .../generator/base/document}/DocumentSupplier.java |  26 +--
 .../generator/base/document}/Documents.java        |   4 +-
 .../generator/base}/util/ClosableUtils.java        |   2 +-
 .../generator/base/util}/CloseableReaper.java      |   6 +-
 .../generator/base}/util/LocaleUtils.java          |   4 +-
 .../base/util/NonClosableWriterWrapper.java        |   6 +-
 .../generator/base}/util/StringUtils.java          |   8 +-
 base/src/test/data/csv/file_01.csv                 |   3 +
 base/src/test/data/csv/file_02.csv                 |   1 +
 base/src/test/data/txt/file_01.txt                 |   2 +
 .../generator/document/DocumentFactoryTest.java    |  84 +++++++++
 .../generator/document}/DocumentTest.java          |  11 +-
 .../generator/document/DocumentsResolverTest.java  |  95 ++++++++++
 .../generator/document}/DocumentsTest.java         |   7 +-
 .../resolver}/RecursiveFileResolverTest.java       |  38 +++-
 cli/pom.xml                                        |  11 +-
 .../freemarker/generator/cli/FreeMarkerTask.java   |  18 +-
 .../org/apache/freemarker/generator/cli/Main.java  |   6 +-
 .../generator/cli/impl/ConfigurationSupplier.java  |   2 +-
 .../generator/cli/impl/ToolsSupplier.java          |   8 +-
 .../freemarker/generator/cli/model/Settings.java   |   6 +-
 .../cli/tools/commonscsv/CommonsCSVTool.java       |   6 +-
 .../generator/cli/tools/excel/ExcelTool.java       |   2 +-
 .../generator/cli/tools/grok/GrokWrapper.java      |   4 +-
 .../generator/cli/tools/jsonpath/JsonPathTool.java |   2 +-
 .../generator/cli/tools/jsoup/JsoupTool.java       |   2 +-
 .../cli/tools/properties/PropertiesTool.java       |   2 +-
 .../cli/tools/snakeyaml/SnakeYamlTool.java         |   2 +-
 .../generator/cli/tools/xml/XmlTool.java           |   2 +-
 .../generator/cli/impl/DocumentsResolverTest.java  |  47 -----
 .../cli/tools/commonscsv/CommonsCSVToolTest.java   |   4 +-
 .../generator/cli/tools/excel/ExcelToolTest.java   |   4 +-
 .../cli/tools/properties/PropertiesToolTest.java   |   4 +-
 .../cli/tools/snakeyaml/SnakeYamlToolTest.java     |   8 +-
 .../generator/cli/tools/xml/XmlToolTest.java       |   4 +-
 pom.xml                                            |   2 +-
 44 files changed, 623 insertions(+), 188 deletions(-)

diff --git a/base/LICENSE b/base/LICENSE
new file mode 100644
index 0000000..8dada3e
--- /dev/null
+++ b/base/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "{}"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright {yyyy} {name of copyright owner}
+
+   Licensed 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.
diff --git a/base/pom.xml b/base/pom.xml
new file mode 100644
index 0000000..64f46da
--- /dev/null
+++ b/base/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.freemarker.generator</groupId>
+        <artifactId>parent</artifactId>
+        <version>0.1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>freemarker-generator-base</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache FreeMarker Generator: CLI Base</name>
+    <description>Command-line client for Apache FreeMarker</description>
+    <inceptionYear>2020</inceptionYear>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <!-- Testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.12</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java b/base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java
similarity index 68%
copy from cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java
copy to base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java
index 9800c72..a58328b 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/activation/ByteArrayDataSource.java
@@ -6,7 +6,7 @@
  * (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
+ *     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,
@@ -14,35 +14,36 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.activation;
+
+package org.apache.freemarker.generator.base.activation;
 
 import javax.activation.DataSource;
+import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 
 import static java.util.Objects.requireNonNull;
 
-public class InputStreamDataSource implements DataSource {
-
+public class ByteArrayDataSource implements DataSource {
     private static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
 
     private final String name;
-    private final InputStream is;
+    private final byte[] content;
     private final String contentType;
 
-    public InputStreamDataSource(String name, InputStream is) {
-        this(name, is, DEFAULT_CONTENT_TYPE);
+    public ByteArrayDataSource(String name, byte[] content) {
+        this(name, content, DEFAULT_CONTENT_TYPE);
     }
 
-    public InputStreamDataSource(String name, InputStream is, String contentType) {
+    public ByteArrayDataSource(String name, byte[] content, String contentType) {
         this.name = requireNonNull(name);
-        this.is = requireNonNull(is);
+        this.content = requireNonNull(content);
         this.contentType = requireNonNull(contentType);
     }
 
     @Override
     public InputStream getInputStream() {
-        return is;
+        return new ByteArrayInputStream(content);
     }
 
     @Override
@@ -62,11 +63,14 @@ public class InputStreamDataSource implements DataSource {
 
     @Override
     public String toString() {
-        return "InputStreamDataSource{" +
+        return "ByteArrayDataSource{" +
                 "name='" + name + '\'' +
-                ", contentType='" + contentType + '\'' +
-                ", inputStream=" + is.getClass().getName() +
+                ", contentType=" + contentType +
+                ", length=" + content.length +
                 '}';
     }
-}
 
+    public byte[] getContent() {
+        return content;
+    }
+}
\ No newline at end of file
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java b/base/src/main/java/org/apache/freemarker/generator/base/activation/InputStreamDataSource.java
similarity index 97%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java
rename to base/src/main/java/org/apache/freemarker/generator/base/activation/InputStreamDataSource.java
index 9800c72..72c0ecb 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/InputStreamDataSource.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/activation/InputStreamDataSource.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.activation;
+package org.apache.freemarker.generator.base.activation;
 
 import javax.activation.DataSource;
 import java.io.InputStream;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/StringDataSource.java b/base/src/main/java/org/apache/freemarker/generator/base/activation/StringDataSource.java
similarity index 95%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/activation/StringDataSource.java
rename to base/src/main/java/org/apache/freemarker/generator/base/activation/StringDataSource.java
index 6a59b70..3c871c5 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/activation/StringDataSource.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/activation/StringDataSource.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.activation;
+package org.apache.freemarker.generator.base.activation;
 
 import javax.activation.DataSource;
 import java.io.ByteArrayInputStream;
@@ -22,8 +22,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.nio.charset.Charset;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
 import static java.util.Objects.requireNonNull;
-import static org.apache.commons.codec.Charsets.UTF_8;
 
 public class StringDataSource implements DataSource {
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolver.java b/base/src/main/java/org/apache/freemarker/generator/base/config/RecursiveFileResolver.java
similarity index 66%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolver.java
rename to base/src/main/java/org/apache/freemarker/generator/base/config/RecursiveFileResolver.java
index 29aa89d..467494b 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolver.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/config/RecursiveFileResolver.java
@@ -14,23 +14,23 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.base.config;
 
 import org.apache.commons.io.filefilter.AndFileFilter;
-import org.apache.commons.io.filefilter.HiddenFileFilter;
 import org.apache.commons.io.filefilter.IOFileFilter;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
-import org.apache.freemarker.generator.cli.util.StringUtils;
 
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
+import static java.util.Collections.emptyList;
 import static java.util.Collections.singletonList;
 import static java.util.Objects.requireNonNull;
 import static java.util.stream.Collectors.toList;
 import static org.apache.commons.io.FileUtils.listFiles;
+import static org.apache.commons.io.filefilter.HiddenFileFilter.VISIBLE;
 
 /**
  * Resolve a list of files or directories recursively and
@@ -38,10 +38,11 @@ import static org.apache.commons.io.FileUtils.listFiles;
  */
 public class RecursiveFileResolver {
 
-    private static final String DEFAULT_INCLUDE = "*";
+    public static final String MATCH_ALL = "*";
 
     private final Collection<String> sources;
-    private final String includes;
+    private final IOFileFilter fileFilter;
+    private final IOFileFilter directoryFilter;
 
     public RecursiveFileResolver(String source, String includes) {
         this(singletonList(source), includes);
@@ -49,7 +50,8 @@ public class RecursiveFileResolver {
 
     public RecursiveFileResolver(Collection<String> sources, String includes) {
         this.sources = requireNonNull(sources);
-        this.includes = StringUtils.isNullOrEmtpty(includes) ? DEFAULT_INCLUDE : includes;
+        this.fileFilter = fileFilter(includes);
+        this.directoryFilter = directoryFilter();
     }
 
     public List<File> resolve() {
@@ -61,22 +63,33 @@ public class RecursiveFileResolver {
 
     private List<File> resolve(String source) {
         final File file = new File(source);
+
         if (file.isFile()) {
-            return singletonList(file);
-        } else {
+            return resolveFile(file);
+        } else if (file.isDirectory()) {
             return new ArrayList<>(resolveDirectory(file));
+        } else {
+            throw new IllegalArgumentException("Unable to find source: " + source);
         }
     }
 
+    private List<File> resolveFile(File file) {
+        return fileFilter.accept(file) ? singletonList(file) : emptyList();
+    }
+
     private List<File> resolveDirectory(File directory) {
-        return new ArrayList<>(listFiles(directory, fileFilter(), directoryFilter()));
+        return new ArrayList<>(listFiles(directory, fileFilter, directoryFilter));
     }
 
-    private IOFileFilter fileFilter() {
-        return new AndFileFilter(new WildcardFileFilter(includes), HiddenFileFilter.VISIBLE);
+    private static IOFileFilter fileFilter(String includes) {
+        if (includes == null || includes.trim().isEmpty()) {
+            return new AndFileFilter(new WildcardFileFilter(MATCH_ALL), VISIBLE);
+        } else {
+            return new AndFileFilter(new WildcardFileFilter(includes), VISIBLE);
+        }
     }
 
     private static IOFileFilter directoryFilter() {
-        return HiddenFileFilter.VISIBLE;
+        return VISIBLE;
     }
 }
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Document.java b/base/src/main/java/org/apache/freemarker/generator/base/document/Document.java
similarity index 91%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/model/Document.java
rename to base/src/main/java/org/apache/freemarker/generator/base/document/Document.java
index 092f760..b5bed63 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Document.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/document/Document.java
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.model;
+package org.apache.freemarker.generator.base.document;
 
-import org.apache.freemarker.generator.cli.activation.StringDataSource;
-import org.apache.freemarker.generator.cli.impl.CloseableReaper;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.LineIterator;
+import org.apache.freemarker.generator.base.activation.ByteArrayDataSource;
+import org.apache.freemarker.generator.base.activation.StringDataSource;
+import org.apache.freemarker.generator.base.util.CloseableReaper;
 
 import javax.activation.DataSource;
 import javax.activation.FileDataSource;
@@ -41,9 +42,9 @@ import static org.apache.commons.io.IOUtils.lineIterator;
  */
 public class Document implements Closeable {
 
-    private static final int UKNOWN_LENGTH = -1;
+    public static final int UNKNOWN_LENGTH = -1;
 
-    /** Human-radable name of the document */
+    /** Human-readable name of the document */
     private final String name;
 
     /** Charset for directly accessing text-based content */
@@ -81,15 +82,17 @@ public class Document implements Closeable {
     /**
      * Try to get the length lazily, efficient and without consuming the input stream.
      *
-     * @return Length of document or "-1"
+     * @return Length of document or UNKNOWN_LENGTH
      */
     public long getLength() {
         if (dataSource instanceof FileDataSource) {
             return ((FileDataSource) dataSource).getFile().length();
         } else if (dataSource instanceof StringDataSource) {
             return ((StringDataSource) dataSource).getContent().length();
+        } else if (dataSource instanceof ByteArrayDataSource) {
+            return ((ByteArrayDataSource) dataSource).getContent().length;
         } else {
-            return UKNOWN_LENGTH;
+            return UNKNOWN_LENGTH;
         }
     }
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentFactory.java b/base/src/main/java/org/apache/freemarker/generator/base/document/DocumentFactory.java
similarity index 72%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentFactory.java
rename to base/src/main/java/org/apache/freemarker/generator/base/document/DocumentFactory.java
index 6fdc01a..b25e5c9 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentFactory.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/document/DocumentFactory.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.base.document;
 
-import org.apache.freemarker.generator.cli.activation.InputStreamDataSource;
-import org.apache.freemarker.generator.cli.activation.StringDataSource;
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.activation.ByteArrayDataSource;
+import org.apache.freemarker.generator.base.activation.InputStreamDataSource;
+import org.apache.freemarker.generator.base.activation.StringDataSource;
 
 import javax.activation.DataSource;
 import javax.activation.FileDataSource;
@@ -35,7 +35,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
  */
 public class DocumentFactory {
 
-    private static final String STRING_LOCATION = "string";
+    private static final String DEFAULT_LOCATION = "unknown";
     private static final String NAME_URL = "url";
 
     private DocumentFactory() {
@@ -48,7 +48,7 @@ public class DocumentFactory {
 
     public static Document create(String name, String content) {
         final StringDataSource dataSource = new StringDataSource(name, content, UTF_8);
-        return create(name, dataSource, STRING_LOCATION, UTF_8);
+        return create(name, dataSource, DEFAULT_LOCATION, UTF_8);
     }
 
     public static Document create(File file, Charset charset) {
@@ -56,6 +56,16 @@ public class DocumentFactory {
         return create(file.getName(), dataSource, file.getAbsolutePath(), charset);
     }
 
+    public static Document create(String name, byte[] content) {
+        final ByteArrayDataSource dataSource = new ByteArrayDataSource(name, content);
+        return create(name, dataSource, DEFAULT_LOCATION, UTF_8);
+    }
+
+    public static Document create(String name, InputStream is, Charset charset) {
+        final InputStreamDataSource dataSource = new InputStreamDataSource(name, is);
+        return create(name, dataSource, DEFAULT_LOCATION, charset);
+    }
+
     public static Document create(String name, InputStream is, String location, Charset charset) {
         final InputStreamDataSource dataSource = new InputStreamDataSource(name, is);
         return create(name, dataSource, location, charset);
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentSupplier.java b/base/src/main/java/org/apache/freemarker/generator/base/document/DocumentSupplier.java
similarity index 76%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentSupplier.java
rename to base/src/main/java/org/apache/freemarker/generator/base/document/DocumentSupplier.java
index 65a8780..7a04522 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/DocumentSupplier.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/document/DocumentSupplier.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.base.document;
 
-import org.apache.freemarker.generator.cli.model.Document;
 
-import java.io.File;
+import org.apache.freemarker.generator.base.config.RecursiveFileResolver;
+
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.nio.charset.Charset;
@@ -61,10 +61,8 @@ public class DocumentSupplier implements Supplier<List<Document>> {
     private List<Document> get(String source) {
         if (isUrl(source)) {
             return singletonList(resolveUrl(source));
-        } else if (isFile(source)) {
-            return singletonList(resolveFile(source, charset));
         } else {
-            return resolveDirectory(source, include, charset);
+            return resolveFile(source, include, charset);
         }
     }
 
@@ -72,28 +70,20 @@ public class DocumentSupplier implements Supplier<List<Document>> {
         return DocumentFactory.create(toUrl(url));
     }
 
-    private Document resolveFile(String name, Charset charset) {
-        return DocumentFactory.create(new File(name), charset);
-    }
-
-    private List<Document> resolveDirectory(String directory, String include, Charset charset) {
-        return fileResolver(directory, include).resolve().stream()
+    private List<Document> resolveFile(String source, String include, Charset charset) {
+        return fileResolver(source, include).resolve().stream()
                 .map(file -> DocumentFactory.create(file, charset))
                 .collect(toList());
     }
 
-    private RecursiveFileResolver fileResolver(String directory, String include) {
-        return new RecursiveFileResolver(directory, include);
+    private RecursiveFileResolver fileResolver(String source, String include) {
+        return new RecursiveFileResolver(source, include);
     }
 
     private static boolean isUrl(String value) {
         return value.startsWith("http://") || value.startsWith("https://");
     }
 
-    private static boolean isFile(String value) {
-        return new File(value).isFile();
-    }
-
     private static URL toUrl(String value) {
         try {
             return new URL(value);
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Documents.java b/base/src/main/java/org/apache/freemarker/generator/base/document/Documents.java
similarity index 95%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/model/Documents.java
rename to base/src/main/java/org/apache/freemarker/generator/base/document/Documents.java
index 9acbfbc..f92681c 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Documents.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/document/Documents.java
@@ -14,9 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.model;
+package org.apache.freemarker.generator.base.document;
 
-import org.apache.freemarker.generator.cli.util.ClosableUtils;
+import org.apache.freemarker.generator.base.util.ClosableUtils;
 
 import java.io.Closeable;
 import java.util.ArrayList;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/util/ClosableUtils.java b/base/src/main/java/org/apache/freemarker/generator/base/util/ClosableUtils.java
similarity index 95%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/util/ClosableUtils.java
rename to base/src/main/java/org/apache/freemarker/generator/base/util/ClosableUtils.java
index e2ed678..dfefc01 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/util/ClosableUtils.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/util/ClosableUtils.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.util;
+package org.apache.freemarker.generator.base.util;
 
 import java.io.Closeable;
 import java.io.IOException;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/CloseableReaper.java b/base/src/main/java/org/apache/freemarker/generator/base/util/CloseableReaper.java
similarity index 88%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/impl/CloseableReaper.java
rename to base/src/main/java/org/apache/freemarker/generator/base/util/CloseableReaper.java
index 37c4699..fb56abe 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/CloseableReaper.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/util/CloseableReaper.java
@@ -14,15 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.base.util;
 
 import java.io.Closeable;
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.List;
 
-import static org.apache.freemarker.generator.cli.util.ClosableUtils.closeQuietly;
-
 /**
  * Keep track of closables created on behalf of the client to close
  * them all later on.
@@ -40,7 +38,7 @@ public class CloseableReaper implements Closeable {
 
     @Override
     public synchronized void close() {
-        closeables.forEach(c -> closeQuietly(c.get()));
+        closeables.forEach(c -> ClosableUtils.closeQuietly(c.get()));
         closeables.clear();
     }
 }
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/util/LocaleUtils.java b/base/src/main/java/org/apache/freemarker/generator/base/util/LocaleUtils.java
similarity index 91%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/util/LocaleUtils.java
rename to base/src/main/java/org/apache/freemarker/generator/base/util/LocaleUtils.java
index c01ab3c..0131568 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/util/LocaleUtils.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/util/LocaleUtils.java
@@ -14,14 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.util;
+package org.apache.freemarker.generator.base.util;
 
 import java.util.Locale;
 
 public class LocaleUtils {
 
     public static Locale parseLocale(String value) {
-        if (StringUtils.isNullOrEmtpty(value)) {
+        if (StringUtils.isEmpty(value)) {
             return Locale.getDefault();
         }
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/NonClosableFreeMarkerWriterWrapper.java b/base/src/main/java/org/apache/freemarker/generator/base/util/NonClosableWriterWrapper.java
similarity index 93%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/impl/NonClosableFreeMarkerWriterWrapper.java
rename to base/src/main/java/org/apache/freemarker/generator/base/util/NonClosableWriterWrapper.java
index 2fe9d55..cef43f5 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/NonClosableFreeMarkerWriterWrapper.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/util/NonClosableWriterWrapper.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.base.util;
 
 import java.io.IOException;
 import java.io.Writer;
@@ -27,11 +27,11 @@ import static java.util.Objects.requireNonNull;
  * Commons CSV integration uses the FreeMarker writer directly but
  * some implementation could call "CSVPrinter#close"
  */
-public class NonClosableFreeMarkerWriterWrapper extends Writer {
+public class NonClosableWriterWrapper extends Writer {
 
     private final Writer delegate;
 
-    public NonClosableFreeMarkerWriterWrapper(Writer delegate) {
+    public NonClosableWriterWrapper(Writer delegate) {
         this.delegate = requireNonNull(delegate);
     }
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/util/StringUtils.java b/base/src/main/java/org/apache/freemarker/generator/base/util/StringUtils.java
similarity index 81%
rename from cli/src/main/java/org/apache/freemarker/generator/cli/util/StringUtils.java
rename to base/src/main/java/org/apache/freemarker/generator/base/util/StringUtils.java
index dfc44ea..769fd06 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/util/StringUtils.java
+++ b/base/src/main/java/org/apache/freemarker/generator/base/util/StringUtils.java
@@ -14,15 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.util;
+package org.apache.freemarker.generator.base.util;
 
 public class StringUtils {
 
-    public static boolean isNullOrEmtpty(String value) {
+    public static boolean isEmpty(String value) {
         return value == null || value.trim().isEmpty();
     }
-
-    public static boolean isNotEmpty(String value) {
-        return !isNullOrEmtpty(value);
-    }
 }
diff --git a/base/src/test/data/csv/file_01.csv b/base/src/test/data/csv/file_01.csv
new file mode 100644
index 0000000..3f4e701
--- /dev/null
+++ b/base/src/test/data/csv/file_01.csv
@@ -0,0 +1,3 @@
+Text;Date;Number;Currency;Time;Percentage;Forumula
+Row 1;01.01.17;100,00;€100,00;10:00;50,00%;50
+Row 2;01.01.17;100,00;€100,00;10:00;50,00%;50
\ No newline at end of file
diff --git a/base/src/test/data/csv/file_02.csv b/base/src/test/data/csv/file_02.csv
new file mode 100644
index 0000000..5b9518d
--- /dev/null
+++ b/base/src/test/data/csv/file_02.csv
@@ -0,0 +1 @@
+Text;Date;Number;Currency;Time;Percentage;Forumula
\ No newline at end of file
diff --git a/base/src/test/data/txt/file_01.txt b/base/src/test/data/txt/file_01.txt
new file mode 100644
index 0000000..ed81d07
--- /dev/null
+++ b/base/src/test/data/txt/file_01.txt
@@ -0,0 +1,2 @@
+Hello
+World
\ No newline at end of file
diff --git a/base/src/test/java/org/apache/freemarker/generator/document/DocumentFactoryTest.java b/base/src/test/java/org/apache/freemarker/generator/document/DocumentFactoryTest.java
new file mode 100644
index 0000000..d837761
--- /dev/null
+++ b/base/src/test/java/org/apache/freemarker/generator/document/DocumentFactoryTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.document;
+
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+
+public class DocumentFactoryTest {
+
+    private static final String ANY_TEXT = "Hello World";
+    private static final String ANY_FILE_NAME = "pom.xml";
+    private static final Charset ANY_CHAR_SET = UTF_8;
+    private static final File ANY_FILE = new File(ANY_FILE_NAME);
+    private static final String UNKOWN_LOCATION = "unknown";
+
+    @Test
+    public void shouldCreateFileBasedDocument() throws IOException {
+        final Document document = DocumentFactory.create(ANY_FILE, ANY_CHAR_SET);
+
+        assertEquals(ANY_FILE_NAME, document.getName());
+        assertEquals(UTF_8, document.getCharset());
+        assertEquals(ANY_FILE.getAbsolutePath(), document.getLocation());
+        assertTrue(document.getLines().size() > 0);
+    }
+
+    @Test
+    public void shouldCreateStringBasedDocument() throws IOException {
+        final Document document = DocumentFactory.create("test.txt", ANY_TEXT);
+
+        assertEquals("test.txt", document.getName());
+        assertEquals(UTF_8, document.getCharset());
+        assertEquals(UNKOWN_LOCATION, document.getLocation());
+        assertEquals(ANY_TEXT, document.getText());
+        assertEquals(1, document.getLines().size());
+    }
+
+    @Test
+    public void shouldCreateByteArrayBasedDocument() throws IOException {
+        final Document document = DocumentFactory.create("test.txt", ANY_TEXT.getBytes(UTF_8));
+
+        assertEquals("test.txt", document.getName());
+        assertEquals(UTF_8, document.getCharset());
+        assertEquals(UNKOWN_LOCATION, document.getLocation());
+        assertEquals(ANY_TEXT, document.getText());
+        assertEquals(1, document.getLines().size());
+    }
+
+    @Test
+    public void shouldCreateInputStreamBasedDocument() throws IOException {
+        final InputStream is = new ByteArrayInputStream(ANY_TEXT.getBytes(UTF_8));
+        final Document document = DocumentFactory.create("test.txt", is, UTF_8);
+
+        assertEquals("test.txt", document.getName());
+        assertEquals(UTF_8, document.getCharset());
+        assertEquals(UNKOWN_LOCATION, document.getLocation());
+        assertEquals(ANY_TEXT, document.getText());
+    }
+
+}
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentTest.java b/base/src/test/java/org/apache/freemarker/generator/document/DocumentTest.java
similarity index 89%
rename from cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentTest.java
rename to base/src/test/java/org/apache/freemarker/generator/document/DocumentTest.java
index 8ec6a12..b3421ac 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentTest.java
+++ b/base/src/test/java/org/apache/freemarker/generator/document/DocumentTest.java
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.model;
+package org.apache.freemarker.generator.document;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
 import org.apache.commons.io.LineIterator;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.junit.Test;
 
 import java.io.File;
@@ -41,7 +42,7 @@ public class DocumentTest {
     public void shouldSupportTextDocument() throws IOException {
         try (Document document = DocumentFactory.create("stdin", ANY_TEXT)) {
             assertEquals("stdin", document.getName());
-            assertEquals("string", document.getLocation());
+            assertEquals("unknown", document.getLocation());
             assertEquals(UTF_8, document.getCharset());
             assertTrue(document.getLength() > 0);
             assertEquals(ANY_TEXT, document.getText());
@@ -60,7 +61,7 @@ public class DocumentTest {
     }
 
     @Test
-    public void shouldSupportLineInterator() throws IOException {
+    public void shouldSupportLineIterator() throws IOException {
         try (Document document = DocumentFactory.create("test", ANY_TEXT)) {
             try (LineIterator iterator = document.getLineIterator(ANY_CHAR_SET.name())) {
                 assertEquals(1, count(iterator));
@@ -83,7 +84,7 @@ public class DocumentTest {
         }
     }
 
-    private static int count(Iterator iterator) {
+    private static int count(Iterator<String> iterator) {
         int count = 0;
         while (iterator.hasNext()) {
             count++;
diff --git a/base/src/test/java/org/apache/freemarker/generator/document/DocumentsResolverTest.java b/base/src/test/java/org/apache/freemarker/generator/document/DocumentsResolverTest.java
new file mode 100644
index 0000000..1e148da
--- /dev/null
+++ b/base/src/test/java/org/apache/freemarker/generator/document/DocumentsResolverTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.document;
+
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentSupplier;
+import org.junit.Test;
+
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.List;
+
+import static java.util.Collections.singletonList;
+import static org.apache.freemarker.generator.base.config.RecursiveFileResolver.MATCH_ALL;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class DocumentsResolverTest {
+
+    private static final String ANY_FILE = "./pom.xml";
+    private static final String ANY_DIRECTORY = "./src/test/data";
+
+    @Test
+    public void shouldResolveSingleFile() {
+        assertEquals(1, supplier(ANY_FILE, MATCH_ALL).get().size());
+    }
+
+    @Test
+    public void shouldResolveMultipleFiles() {
+        final List<String> sources = Arrays.asList("pom.xml", "LICENSE");
+        assertEquals(2, supplier(sources, null).get().size());
+        assertEquals(2, supplier(sources, "").get().size());
+        assertEquals(2, supplier(sources, "*").get().size());
+        assertEquals(1, supplier(sources, "*.xml").get().size());
+        assertEquals(1, supplier(sources, "*.x**").get().size());
+        assertEquals(1, supplier(sources, "LICENSE").get().size());
+        assertEquals(0, supplier(sources, "*.bin").get().size());
+    }
+
+    @Test
+    public void shouldResolveDirectory() {
+        assertEquals(3, supplier(ANY_DIRECTORY, null).get().size());
+        assertEquals(3, supplier(ANY_DIRECTORY, "").get().size());
+        assertEquals(3, supplier(ANY_DIRECTORY, "*").get().size());
+        assertEquals(2, supplier(ANY_DIRECTORY, "*.csv").get().size());
+        assertEquals(1, supplier(ANY_DIRECTORY, "*.t*").get().size());
+        assertEquals(0, supplier(ANY_DIRECTORY, "*.bin").get().size());
+    }
+
+    @Test
+    public void shouldResolveFilesAndDirectory() {
+        final List<String> sources = Arrays.asList("pom.xml", "LICENSE", ANY_DIRECTORY);
+        assertEquals(5, supplier(sources, null).get().size());
+        assertEquals(5, supplier(sources, "").get().size());
+        assertEquals(5, supplier(sources, "*").get().size());
+        assertEquals(2, supplier(sources, "*.csv").get().size());
+        assertEquals(1, supplier(sources, "*.t*").get().size());
+        assertEquals(1, supplier(sources, "*.xml").get().size());
+        assertEquals(0, supplier(sources, "*.bin").get().size());
+    }
+
+    @Test
+    public void shouldResolveLargeDirectory() {
+        final List<Document> documents = supplier(".", null).get();
+        assertTrue(documents.size() > 0);
+    }
+
+    @Test(expected = RuntimeException.class)
+    public void shouldThrowExceptionForNonexistingSourceDirectory() {
+        assertEquals(0, supplier("/does-not-exist", MATCH_ALL).get().size());
+    }
+
+    private static DocumentSupplier supplier(String directory, String include) {
+        return new DocumentSupplier(singletonList(directory), include, Charset.defaultCharset());
+    }
+
+    private static DocumentSupplier supplier(List<String> files, String include) {
+        return new DocumentSupplier(files, include, Charset.defaultCharset());
+    }
+
+}
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentsTest.java b/base/src/test/java/org/apache/freemarker/generator/document/DocumentsTest.java
similarity index 93%
rename from cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentsTest.java
rename to base/src/test/java/org/apache/freemarker/generator/document/DocumentsTest.java
index b653aa5..5848f46 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/model/DocumentsTest.java
+++ b/base/src/test/java/org/apache/freemarker/generator/document/DocumentsTest.java
@@ -14,9 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.model;
+package org.apache.freemarker.generator.document;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
+import org.apache.freemarker.generator.base.document.Documents;
 import org.junit.Test;
 
 import java.io.File;
@@ -104,5 +106,4 @@ public class DocumentsTest {
             throw new RuntimeException(e);
         }
     }
-
 }
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolverTest.java b/base/src/test/java/org/apache/freemarker/generator/resolver/RecursiveFileResolverTest.java
similarity index 57%
rename from cli/src/test/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolverTest.java
rename to base/src/test/java/org/apache/freemarker/generator/resolver/RecursiveFileResolverTest.java
index 5888ce1..dc619bf 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/impl/RecursiveFileResolverTest.java
+++ b/base/src/test/java/org/apache/freemarker/generator/resolver/RecursiveFileResolverTest.java
@@ -14,11 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.freemarker.generator.cli.impl;
+package org.apache.freemarker.generator.resolver;
 
+import org.apache.freemarker.generator.base.config.RecursiveFileResolver;
 import org.junit.Test;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.List;
 
 import static java.util.Collections.singletonList;
@@ -27,13 +29,13 @@ import static org.junit.Assert.assertTrue;
 
 public class RecursiveFileResolverTest {
 
-    private static final String ANY_DIRECTORY = ".";
-    private static final String ANY_FILE_NAME = "CHANGELOG.md";
+    private static final String ANY_DIRECTORY = "./src/test/data";
+    private static final String ANY_FILE_NAME = "file_01.csv";
     private static final String UNKNOWN_FILE_NAME = "unknown.file";
 
     @Test
     public void shouldResolveAllFilesOfDirectory() {
-        assertTrue(fileResolver(ANY_DIRECTORY, null).resolve().size() > 100);
+        assertEquals(3, fileResolver(ANY_DIRECTORY, null).resolve().size());
         assertTrue(fileResolver(ANY_DIRECTORY, UNKNOWN_FILE_NAME).resolve().isEmpty());
     }
 
@@ -46,13 +48,37 @@ public class RecursiveFileResolverTest {
     }
 
     @Test
+    public void shouldResolveMultipleFiles() {
+        final List<String> sources = Arrays.asList("pom.xml", "LICENSE");
+        final List<File> files = fileResolver(sources, "*").resolve();
+
+        assertEquals(2, files.size());
+        assertEquals("pom.xml", files.get(0).getName());
+        assertEquals("LICENSE", files.get(1).getName());
+    }
+
+    @Test
+    public void shouldResolveMultipleFilesWithIncludeFilter() {
+        final List<String> sources = Arrays.asList("pom.xml", "LICENSE");
+        final List<File> files = fileResolver(sources, "*.xml").resolve();
+
+        assertEquals(1, files.size());
+        assertEquals("pom.xml", files.get(0).getName());
+    }
+
+    @Test
     public void shouldResolveMultipleFilesRecursivelyWithIncludes() {
-        final List<File> files = fileResolver("./site", "*.csv").resolve();
+        final List<File> files = fileResolver(ANY_DIRECTORY, "*.csv").resolve();
 
-        assertEquals(5, files.size());
+        assertEquals(2, files.size());
     }
 
     private static RecursiveFileResolver fileResolver(String directory, String include) {
         return new RecursiveFileResolver(singletonList(directory), include);
     }
+
+    private static RecursiveFileResolver fileResolver(List<String> sources, String include) {
+        return new RecursiveFileResolver(sources, include);
+    }
+
 }
diff --git a/cli/pom.xml b/cli/pom.xml
index 7941212..c88e2cc 100644
--- a/cli/pom.xml
+++ b/cli/pom.xml
@@ -179,6 +179,11 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.freemarker.generator</groupId>
+            <artifactId>freemarker-generator-base</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
             <groupId>io.krakens</groupId>
             <artifactId>java-grok</artifactId>
             <version>0.1.9</version>
@@ -225,11 +230,7 @@
             <artifactId>commons-exec</artifactId>
             <version>1.3</version>
         </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>2.6</version>
-        </dependency>
+
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-csv</artifactId>
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/FreeMarkerTask.java b/cli/src/main/java/org/apache/freemarker/generator/cli/FreeMarkerTask.java
index e4ec0f8..9754f1e 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/FreeMarkerTask.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/FreeMarkerTask.java
@@ -16,18 +16,18 @@
  */
 package org.apache.freemarker.generator.cli;
 
-import org.apache.freemarker.generator.cli.impl.ConfigurationSupplier;
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.impl.DocumentSupplier;
-import org.apache.freemarker.generator.cli.impl.TemplateLoaderSupplier;
-import org.apache.freemarker.generator.cli.impl.ToolsSupplier;
-import org.apache.freemarker.generator.cli.model.Document;
-import org.apache.freemarker.generator.cli.model.Documents;
-import org.apache.freemarker.generator.cli.model.Settings;
 import freemarker.cache.TemplateLoader;
 import freemarker.template.Configuration;
 import freemarker.template.Template;
 import org.apache.commons.io.FileUtils;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
+import org.apache.freemarker.generator.base.document.DocumentSupplier;
+import org.apache.freemarker.generator.base.document.Documents;
+import org.apache.freemarker.generator.cli.impl.ConfigurationSupplier;
+import org.apache.freemarker.generator.cli.impl.TemplateLoaderSupplier;
+import org.apache.freemarker.generator.cli.impl.ToolsSupplier;
+import org.apache.freemarker.generator.cli.model.Settings;
 
 import java.io.File;
 import java.io.IOException;
@@ -110,7 +110,7 @@ public class FreeMarkerTask implements Callable<Integer> {
      * which are mostly irrelevant when running on the command line. So we resolve the absolute file
      * instead of relying on existing template loaders.
      *
-     * @param settings Settings
+     * @param settings              Settings
      * @param configurationSupplier Supplies FreeMarker configuration
      * @return FreeMarker template
      */
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/Main.java b/cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
index 5a00670..c16a617 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/Main.java
@@ -16,12 +16,12 @@
  */
 package org.apache.freemarker.generator.cli;
 
+import org.apache.freemarker.generator.base.util.ClosableUtils;
+import org.apache.freemarker.generator.base.util.StringUtils;
 import org.apache.freemarker.generator.cli.impl.PropertiesFileResolver;
 import org.apache.freemarker.generator.cli.impl.TemplateDirectorySupplier;
 import org.apache.freemarker.generator.cli.model.Settings;
 import org.apache.freemarker.generator.cli.picocli.GitVersionProvider;
-import org.apache.freemarker.generator.cli.util.ClosableUtils;
-import org.apache.freemarker.generator.cli.util.StringUtils;
 import picocli.CommandLine;
 import picocli.CommandLine.ArgGroup;
 import picocli.CommandLine.Command;
@@ -180,7 +180,7 @@ public class Main implements Callable<Integer> {
         try {
             if (userSuppliedWriter != null) {
                 return userSuppliedWriter;
-            } else if (StringUtils.isNotEmpty(outputFile)) {
+            } else if (!StringUtils.isEmpty(outputFile)) {
                 return new BufferedWriter(new FileWriter(outputFile));
             } else {
                 return new BufferedWriter(new OutputStreamWriter(System.out, ouputEncoding));
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ConfigurationSupplier.java b/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ConfigurationSupplier.java
index 7d677be..cf95d6a 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ConfigurationSupplier.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ConfigurationSupplier.java
@@ -16,13 +16,13 @@
  */
 package org.apache.freemarker.generator.cli.impl;
 
-import org.apache.freemarker.generator.cli.model.Settings;
 import freemarker.cache.TemplateLoader;
 import freemarker.template.Configuration;
 import freemarker.template.DefaultObjectWrapper;
 import freemarker.template.DefaultObjectWrapperBuilder;
 import freemarker.template.TemplateExceptionHandler;
 import freemarker.template.Version;
+import org.apache.freemarker.generator.cli.model.Settings;
 
 import java.util.function.Supplier;
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ToolsSupplier.java b/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ToolsSupplier.java
index 4be6ff6..c06c981 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ToolsSupplier.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/impl/ToolsSupplier.java
@@ -74,22 +74,22 @@ public class ToolsSupplier implements Supplier<Map<String, Object>> {
         try {
             final Class<?> clazz = Class.forName(clazzName);
             final Constructor<?>[] constructors = clazz.getConstructors();
-            final Constructor constructorWithSettings = findSingleParameterConstructor(constructors, Map.class);
-            final Constructor defaultConstructor = findDefaultConstructor(constructors);
+            final Constructor<?> constructorWithSettings = findSingleParameterConstructor(constructors, Map.class);
+            final Constructor<?> defaultConstructor = findDefaultConstructor(constructors);
             return constructorWithSettings != null ? constructorWithSettings.newInstance(settings) : defaultConstructor.newInstance();
         } catch (Exception e) {
             throw new RuntimeException("Failed to create tool: " + clazzName, e);
         }
     }
 
-    private static Constructor findSingleParameterConstructor(Constructor[] constructors, Class parameterClazz) {
+    private static Constructor<?> findSingleParameterConstructor(Constructor<?>[] constructors, Class<?> parameterClazz) {
         return stream(constructors)
                 .filter(c -> c.getParameterCount() == 1 && c.getParameterTypes()[0].equals(parameterClazz))
                 .findFirst()
                 .orElse(null);
     }
 
-    private static Constructor findDefaultConstructor(Constructor[] constructors) {
+    private static Constructor<?> findDefaultConstructor(Constructor<?>[] constructors) {
         return stream(constructors)
                 .filter(c -> c.getParameterCount() == 0)
                 .findFirst()
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Settings.java b/cli/src/main/java/org/apache/freemarker/generator/cli/model/Settings.java
index ef1a291..84b99be 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/model/Settings.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/model/Settings.java
@@ -16,8 +16,8 @@
  */
 package org.apache.freemarker.generator.cli.model;
 
-import org.apache.freemarker.generator.cli.impl.NonClosableFreeMarkerWriterWrapper;
-import org.apache.freemarker.generator.cli.util.LocaleUtils;
+import org.apache.freemarker.generator.base.util.LocaleUtils;
+import org.apache.freemarker.generator.base.util.NonClosableWriterWrapper;
 
 import java.io.File;
 import java.io.Writer;
@@ -124,7 +124,7 @@ public class Settings {
         this.sources = requireNonNull(sources);
         this.properties = requireNonNull(properties);
         this.configuration = requireNonNull(configuration);
-        this.writer = new NonClosableFreeMarkerWriterWrapper(requireNonNull(writer));
+        this.writer = new NonClosableWriterWrapper(requireNonNull(writer));
     }
 
     public static SettingsBuilder builder() {
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVTool.java
index 5b8dc1c..0470579 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVTool.java
@@ -16,13 +16,13 @@
  */
 package org.apache.freemarker.generator.cli.tools.commonscsv;
 
-import org.apache.freemarker.generator.cli.model.Document;
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
 import org.apache.commons.csv.CSVPrinter;
 import org.apache.commons.csv.CSVRecord;
 import org.apache.commons.io.input.BOMInputStream;
-import org.apache.freemarker.generator.cli.util.StringUtils;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.util.StringUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -61,7 +61,7 @@ public class CommonsCSVTool {
     }
 
     public CSVParser parse(String csv, CSVFormat format) {
-        if (StringUtils.isNullOrEmtpty(csv)) {
+        if (StringUtils.isEmpty(csv)) {
             throw new IllegalArgumentException("No CSV was provided");
         }
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/excel/ExcelTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/excel/ExcelTool.java
index 1857829..7e14232 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/excel/ExcelTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/excel/ExcelTool.java
@@ -16,7 +16,7 @@
  */
 package org.apache.freemarker.generator.cli.tools.excel;
 
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.DataFormatter;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/grok/GrokWrapper.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/grok/GrokWrapper.java
index 34492c2..f1205a1 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/grok/GrokWrapper.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/grok/GrokWrapper.java
@@ -17,7 +17,7 @@
 package org.apache.freemarker.generator.cli.tools.grok;
 
 import io.krakens.grok.api.Grok;
-import org.apache.freemarker.generator.cli.util.StringUtils;
+import org.apache.freemarker.generator.base.util.StringUtils;
 
 import java.util.Collections;
 import java.util.Map;
@@ -33,7 +33,7 @@ public class GrokWrapper {
     }
 
     public Map<String, Object> match(String line) {
-        if (StringUtils.isNullOrEmtpty(line)) {
+        if (StringUtils.isEmpty(line)) {
             return Collections.emptyMap();
         }
 
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsonpath/JsonPathTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsonpath/JsonPathTool.java
index a1f224e..543b57f 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsonpath/JsonPathTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsonpath/JsonPathTool.java
@@ -16,11 +16,11 @@
  */
 package org.apache.freemarker.generator.cli.tools.jsonpath;
 
-import org.apache.freemarker.generator.cli.model.Document;
 import com.jayway.jsonpath.Configuration;
 import com.jayway.jsonpath.DocumentContext;
 import com.jayway.jsonpath.JsonPath;
 import com.jayway.jsonpath.Option;
+import org.apache.freemarker.generator.base.document.Document;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsoup/JsoupTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsoup/JsoupTool.java
index f91f62a..b6eb9fb 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsoup/JsoupTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/jsoup/JsoupTool.java
@@ -16,7 +16,7 @@
  */
 package org.apache.freemarker.generator.cli.tools.jsoup;
 
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
 import org.jsoup.Jsoup;
 
 import java.io.IOException;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesTool.java
index f2a261d..80f6d37 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesTool.java
@@ -16,7 +16,7 @@
  */
 package org.apache.freemarker.generator.cli.tools.properties;
 
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
 
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlTool.java
index 12f636a..6494b7c 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlTool.java
@@ -16,7 +16,7 @@
  */
 package org.apache.freemarker.generator.cli.tools.snakeyaml;
 
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
 import org.yaml.snakeyaml.Yaml;
 
 import java.io.IOException;
diff --git a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/xml/XmlTool.java b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/xml/XmlTool.java
index 8f0fab2..9980391 100644
--- a/cli/src/main/java/org/apache/freemarker/generator/cli/tools/xml/XmlTool.java
+++ b/cli/src/main/java/org/apache/freemarker/generator/cli/tools/xml/XmlTool.java
@@ -16,8 +16,8 @@
  */
 package org.apache.freemarker.generator.cli.tools.xml;
 
-import org.apache.freemarker.generator.cli.model.Document;
 import freemarker.ext.dom.NodeModel;
+import org.apache.freemarker.generator.base.document.Document;
 import org.xml.sax.InputSource;
 
 import java.io.InputStream;
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/impl/DocumentsResolverTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/impl/DocumentsResolverTest.java
deleted file mode 100644
index 1f688a2..0000000
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/impl/DocumentsResolverTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.cli.impl;
-
-import org.junit.Test;
-
-import java.nio.charset.Charset;
-
-import static java.util.Collections.singletonList;
-import static org.junit.Assert.assertEquals;
-
-public class DocumentsResolverTest {
-
-    private static final String ANY_DIRECTORY = "./site/sample";
-
-    @Test
-    public void shouldResolveFilesOfDirectory() {
-        assertEquals(18, supplier(ANY_DIRECTORY, null).get().size());
-        assertEquals(18, supplier(ANY_DIRECTORY, "").get().size());
-        assertEquals(18, supplier(ANY_DIRECTORY, "*").get().size());
-        assertEquals(5, supplier(ANY_DIRECTORY, "*.csv").get().size());
-        assertEquals(4, supplier(ANY_DIRECTORY, "*.x*").get().size());
-    }
-
-    @Test(expected = RuntimeException.class)
-    public void shoulThrowExceptionForNonexistingSourceDirectory() {
-        assertEquals(0, supplier("/does-not-exist", null).get().size());
-    }
-
-    private static DocumentSupplier supplier(String directory, String include) {
-        return new DocumentSupplier(singletonList(directory), include, Charset.defaultCharset());
-    }
-}
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVToolTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVToolTest.java
index c4eeebd..804766d 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVToolTest.java
+++ b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/commonscsv/CommonsCSVToolTest.java
@@ -16,12 +16,12 @@
  */
 package org.apache.freemarker.generator.cli.tools.commonscsv;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.model.Document;
 import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
 import org.apache.commons.csv.CSVPrinter;
 import org.apache.commons.csv.CSVRecord;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.junit.Test;
 
 import java.io.File;
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/excel/ExcelToolTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/excel/ExcelToolTest.java
index c30c628..b39bd40 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/excel/ExcelToolTest.java
+++ b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/excel/ExcelToolTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.freemarker.generator.cli.tools.excel;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Test;
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesToolTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesToolTest.java
index c01b816..5b649d7 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesToolTest.java
+++ b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/properties/PropertiesToolTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.freemarker.generator.cli.tools.properties;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.junit.Test;
 
 import static junit.framework.TestCase.assertEquals;
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlToolTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlToolTest.java
index f94153a..4f22e7f 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlToolTest.java
+++ b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/snakeyaml/SnakeYamlToolTest.java
@@ -16,8 +16,8 @@
  */
 package org.apache.freemarker.generator.cli.tools.snakeyaml;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.model.Document;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.junit.Test;
 
 import java.util.List;
@@ -39,7 +39,7 @@ public class SnakeYamlToolTest {
             final Map<String, Object> map = snakeYamlTool().parse(document);
 
             assertEquals(1, map.size());
-            assertEquals(3, ((List) map.get("docker")).size());
+            assertEquals(3, ((List<?>) map.get("docker")).size());
         }
     }
 
@@ -48,7 +48,7 @@ public class SnakeYamlToolTest {
         final Map<String, Object> map = snakeYamlTool().parse(ANY_YAML_STRING);
 
         assertEquals(1, map.size());
-        assertEquals(3, ((List) map.get("docker")).size());
+        assertEquals(3, ((List<?>) map.get("docker")).size());
     }
 
     private SnakeYamlTool snakeYamlTool() {
diff --git a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/xml/XmlToolTest.java b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/xml/XmlToolTest.java
index 199f936..75343f8 100644
--- a/cli/src/test/java/org/apache/freemarker/generator/cli/tools/xml/XmlToolTest.java
+++ b/cli/src/test/java/org/apache/freemarker/generator/cli/tools/xml/XmlToolTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.freemarker.generator.cli.tools.xml;
 
-import org.apache.freemarker.generator.cli.impl.DocumentFactory;
-import org.apache.freemarker.generator.cli.model.Document;
 import freemarker.ext.dom.NodeModel;
+import org.apache.freemarker.generator.base.document.Document;
+import org.apache.freemarker.generator.base.document.DocumentFactory;
 import org.junit.Test;
 
 import static junit.framework.TestCase.assertEquals;
diff --git a/pom.xml b/pom.xml
index f7353e6..4a82971 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,6 +50,7 @@
     </scm>
 
     <modules>
+        <module>base</module>
         <module>cli</module>
         <module>maven-plugin</module>
     </modules>
@@ -72,7 +73,6 @@
 
     <build>
         <pluginManagement>
-
             <plugins>
                 <plugin>
                     <artifactId>maven-antrun-plugin</artifactId>