2 * This file is part of yosql. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of yosql,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
8 package wtf
.metio
.yosql
.tooling
.gradle
;
10 import org
.gradle
.api
.file
.DirectoryProperty
;
11 import org
.gradle
.api
.file
.ProjectLayout
;
12 import org
.gradle
.api
.model
.ObjectFactory
;
13 import org
.gradle
.api
.provider
.Property
;
14 import org
.gradle
.api
.tasks
.InputDirectory
;
15 import org
.gradle
.api
.tasks
.Internal
;
16 import org
.gradle
.api
.tasks
.OutputDirectory
;
17 import wtf
.metio
.yosql
.models
.immutables
.FilesConfiguration
;
20 * Configures input- and output-directories as well as other file related options.
22 public abstract class Files
{
24 private final ObjectFactory objectFactory
;
27 * @return The base path of the input directory.
30 abstract public DirectoryProperty
inputBaseDirectory();
33 * @return The base path of the output directory.
36 abstract public DirectoryProperty
outputBaseDirectory();
39 Property
<FilesConfiguration
> fileConfiguration() {
40 final var files
= objectFactory
.property(FilesConfiguration
.class);
41 files
.set(FilesConfiguration
.usingDefaults()
42 .setInputBaseDirectory(inputBaseDirectory().get().getAsFile().toPath())
43 .setOutputBaseDirectory(outputBaseDirectory().get().getAsFile().toPath())
48 Files(final ObjectFactory objectFactory
, final ProjectLayout projectLayout
) {
49 this.objectFactory
= objectFactory
;
50 inputBaseDirectory().convention(projectLayout
.getProjectDirectory().dir("src").dir("main").dir("yosql"));
51 outputBaseDirectory().convention(projectLayout
.getBuildDirectory().dir("generated").map(d
-> d
.dir("sources").dir("yosql")));