Disentangle various dependencies.
This commit is contained in:
parent
c7ec02a901
commit
e462c60646
@ -53,6 +53,10 @@ public class DefaultObjectFactoryConfigurator implements ObjectFactoryConfigurat
|
||||
new SsgException("the baseUrl Property in " + buildSpec.getName() + " must be set.")
|
||||
)));
|
||||
|
||||
registry.bind(WvcCompilerFactory.class, toSingleton(buildSpec.getWvcCompilerFactory().get(() ->
|
||||
new SsgException("the wvcCompilerFactory Property in " + buildSpec.getName() + " must be set.")
|
||||
)));
|
||||
|
||||
// self binding
|
||||
registry.bind(ObjectFactory.class, toSingleton(registryObjectFactory));
|
||||
});
|
||||
|
||||
@ -47,7 +47,9 @@ class DefaultPageContextFactory implements PageContextFactory {
|
||||
|
||||
// set the template
|
||||
if (component.componentTemplate == null && !wvcClass.isAnnotationPresent(SkipTemplate)) {
|
||||
def compileResult = buildObjectFactory.createInstance(WvcCompiler).compileTemplate(
|
||||
def wvcCompilerFactory = buildObjectFactory.createInstance(WvcCompilerFactory)
|
||||
def wvcCompiler = wvcCompilerFactory.getWvcCompiler()
|
||||
def compileResult = wvcCompiler.compileTemplate(
|
||||
wvcClass,
|
||||
wvcClass.simpleName + 'Template.wvc'
|
||||
)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package com.jessebrault.ssg.buildscript
|
||||
|
||||
import com.jessebrault.di.ObjectFactory
|
||||
import com.jessebrault.ssg.buildscript.delegates.BuildDelegate
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.Nullable
|
||||
|
||||
@ -2,6 +2,7 @@ package com.jessebrault.ssg.buildscript
|
||||
|
||||
import com.jessebrault.di.RegistryObjectFactory
|
||||
import com.jessebrault.fp.provider.Provider
|
||||
import com.jessebrault.ssg.WvcCompilerFactory
|
||||
import com.jessebrault.ssg.model.Model
|
||||
import com.jessebrault.ssg.text.TextSupplier
|
||||
import groovy.transform.EqualsAndHashCode
|
||||
@ -23,6 +24,7 @@ final class BuildSpec {
|
||||
final Provider<Set<Model>> models
|
||||
final Provider<Set<TextSupplier>> textSuppliers
|
||||
final Provider<RegistryObjectFactory> objectFactory
|
||||
final Provider<WvcCompilerFactory> wvcCompilerFactory
|
||||
|
||||
@SuppressWarnings('GroovyAssignabilityCheck')
|
||||
BuildSpec(Map args) {
|
||||
@ -35,6 +37,7 @@ final class BuildSpec {
|
||||
this.models = requireProvider(args.models)
|
||||
this.textSuppliers = requireProvider(args.textSuppliers)
|
||||
this.objectFactory = requireProvider(args.objectFactory)
|
||||
this.wvcCompilerFactory = requireProvider(args.wvcCompilerFactory)
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -5,6 +5,7 @@ import com.jessebrault.fp.property.DefaultProperty
|
||||
import com.jessebrault.fp.property.Property
|
||||
import com.jessebrault.fp.provider.NamedProvider
|
||||
import com.jessebrault.fp.provider.Provider
|
||||
import com.jessebrault.ssg.WvcCompilerFactory
|
||||
import com.jessebrault.ssg.model.Model
|
||||
import com.jessebrault.ssg.model.Models
|
||||
import com.jessebrault.ssg.text.TextSupplier
|
||||
@ -23,6 +24,7 @@ final class BuildDelegate {
|
||||
final Property<Set<Model>> models = DefaultProperty.<Set<Model>>empty(Set)
|
||||
final Property<Set<TextSupplier>> textSuppliers = DefaultProperty.<Set<TextSupplier>>empty(Set)
|
||||
final Property<RegistryObjectFactory> objectFactory = DefaultProperty.empty(RegistryObjectFactory)
|
||||
final Property<WvcCompilerFactory> wvcCompilerFactory = DefaultProperty.empty(WvcCompilerFactory)
|
||||
|
||||
BuildDelegate(File projectDir) {
|
||||
this.projectDir = projectDir
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.jessebrault.ssg.buildscript.delegates
|
||||
|
||||
import com.jessebrault.di.DefaultRegistryObjectFactory
|
||||
import com.jessebrault.ssg.WvcCompilerFactory
|
||||
import com.jessebrault.ssg.model.Model
|
||||
import com.jessebrault.ssg.text.TextSupplier
|
||||
import com.jessebrault.ssg.text.TextsDirMarkdownTextSupplier
|
||||
@ -14,14 +15,17 @@ class DefaultBuildDelegateConfigurator implements BuildDelegateConfigurator {
|
||||
|
||||
private final File projectDir
|
||||
private final TextsDirMarkdownTextSupplier textsDirMarkdownTextSupplier
|
||||
private final WvcCompilerFactory wvcCompilerFactory
|
||||
|
||||
@Inject
|
||||
DefaultBuildDelegateConfigurator(
|
||||
@Named('projectDir') File projectDir,
|
||||
TextsDirMarkdownTextSupplier textsDirMarkdownTextSupplier
|
||||
TextsDirMarkdownTextSupplier textsDirMarkdownTextSupplier,
|
||||
WvcCompilerFactory wvcCompilerFactory
|
||||
) {
|
||||
this.projectDir = projectDir
|
||||
this.textsDirMarkdownTextSupplier = textsDirMarkdownTextSupplier
|
||||
this.wvcCompilerFactory = wvcCompilerFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,6 +37,7 @@ class DefaultBuildDelegateConfigurator implements BuildDelegateConfigurator {
|
||||
models.convention = [] as Set<Model>
|
||||
textSuppliers.convention = [this.textsDirMarkdownTextSupplier] as Set<TextSupplier>
|
||||
objectFactory.convention = DefaultRegistryObjectFactory.Builder.withDefaults().build()
|
||||
wvcCompilerFactory.convention = this.wvcCompilerFactory
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,8 @@ class DefaultBuildDelegateConverter implements BuildDelegateConverter {
|
||||
globals: delegate.globals,
|
||||
models: delegate.models,
|
||||
textSuppliers: delegate.textSuppliers,
|
||||
objectFactory: delegate.objectFactory
|
||||
objectFactory: delegate.objectFactory,
|
||||
wvcCompilerFactory: delegate.wvcCompilerFactory
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.jessebrault.ssg.text;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Named;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -23,7 +22,7 @@ public class TextsDirMarkdownTextSupplier implements TextSupplier {
|
||||
|
||||
@Inject
|
||||
public TextsDirMarkdownTextSupplier(
|
||||
@Named("projectDir") File projectDir,
|
||||
File projectDir,
|
||||
ExecutorService executorService,
|
||||
MarkdownTextConverter markdownTextConverter
|
||||
) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user