OutputDir no longer accepts null constructor param.
This commit is contained in:
parent
3803b26c04
commit
f611aa3227
@ -12,7 +12,7 @@ final class SimpleBuildTasksConverter implements BuildTasksConverter {
|
|||||||
Result<Collection<Task>> convert(Build build) {
|
Result<Collection<Task>> convert(Build build) {
|
||||||
def taskSpec = new TaskSpec(
|
def taskSpec = new TaskSpec(
|
||||||
build.name,
|
build.name,
|
||||||
build.outputDirFunction.apply(build).file,
|
build.outputDirFunction.apply(build).asFile(),
|
||||||
build.siteSpec,
|
build.siteSpec,
|
||||||
build.globals
|
build.globals
|
||||||
)
|
)
|
||||||
|
@ -1,24 +1,41 @@
|
|||||||
package com.jessebrault.ssg.buildscript
|
package com.jessebrault.ssg.buildscript
|
||||||
|
|
||||||
import groovy.transform.EqualsAndHashCode
|
import groovy.transform.EqualsAndHashCode
|
||||||
import org.jetbrains.annotations.Nullable
|
import groovy.transform.NullCheck
|
||||||
|
|
||||||
|
@NullCheck
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
final class OutputDir {
|
final class OutputDir {
|
||||||
|
|
||||||
@Nullable
|
|
||||||
final String path
|
final String path
|
||||||
|
|
||||||
OutputDir(@Nullable String path) {
|
OutputDir(String path) {
|
||||||
this.path = path
|
this.path = path
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputDir(File file) {
|
OutputDir(File file) {
|
||||||
this.path = file.path
|
this(file.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
File getFile() {
|
File asFile() {
|
||||||
this.path ? new File(this.path) : new File('')
|
new File(this.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
String asString() {
|
||||||
|
this.path
|
||||||
|
}
|
||||||
|
|
||||||
|
Object asType(Class<?> clazz) {
|
||||||
|
switch (clazz) {
|
||||||
|
case File -> this.asFile()
|
||||||
|
case String -> this.asString()
|
||||||
|
default -> throw new IllegalArgumentException('cannot cast to a class other than File or String')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String toString() {
|
||||||
|
"OutputDir(path: ${ this.path })"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.jessebrault.ssg.buildscript
|
package com.jessebrault.ssg.buildscript
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable
|
|
||||||
|
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
|
|
||||||
final class OutputDirFunctions {
|
final class OutputDirFunctions {
|
||||||
@ -19,7 +17,7 @@ final class OutputDirFunctions {
|
|||||||
return { new OutputDir(dir) }
|
return { new OutputDir(dir) }
|
||||||
}
|
}
|
||||||
|
|
||||||
static Function<Build, OutputDir> of(@Nullable String path) {
|
static Function<Build, OutputDir> of(String path) {
|
||||||
return { new OutputDir(path) }
|
return { new OutputDir(path) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package com.jessebrault.ssg.buildscript.dsl
|
|||||||
import com.jessebrault.ssg.buildscript.Build
|
import com.jessebrault.ssg.buildscript.Build
|
||||||
import com.jessebrault.ssg.buildscript.OutputDir
|
import com.jessebrault.ssg.buildscript.OutputDir
|
||||||
import com.jessebrault.ssg.buildscript.OutputDirFunctions
|
import com.jessebrault.ssg.buildscript.OutputDirFunctions
|
||||||
import org.jetbrains.annotations.Nullable
|
|
||||||
|
|
||||||
import java.util.function.Function
|
import java.util.function.Function
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ final class BuildDelegate extends AbstractBuildDelegate<Build> {
|
|||||||
this.outputDirFunction = OutputDirFunctions.of(file)
|
this.outputDirFunction = OutputDirFunctions.of(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOutputDir(@Nullable String path) {
|
void setOutputDir(String path) {
|
||||||
this.outputDirFunction = OutputDirFunctions.of(path)
|
this.outputDirFunction = OutputDirFunctions.of(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user