apple / pkl-spring

Spring Boot extension for configuring Boot apps with Pkl
https://pkl-lang.org/spring/current/index.html
Apache License 2.0
40 stars 3 forks source link

Spring boot with Maven ? How to use pkl ? Help provide examples #2

Open arundotin opened 9 months ago

arundotin commented 9 months ago

I am following this instruction here https://pkl-lang.org/spring/current/usage.html to configure pkl for my spring boot app (using Maven build tool)

But this document has only instructions for Gradle build tool. For build tools other than grade, it is been asked there to use pkl-codegen-java dependency which when I use it gets in to conflict with pkl-spring dependency due to lot of duplicate classes

This is my maven dependency

<dependency>
  <groupId>org.pkl-lang</groupId>
  <artifactId>pkl-spring</artifactId>
  <version>0.15.0</version>
  <scope>compile</scope>
</dependency>

When i also add pkl-codegen-java

<dependency>
    <groupId>org.pkl-lang</groupId>
    <artifactId>pkl-codegen-java</artifactId>
    <version>0.25.2</version>
  </dependency>

Then i get this error

[ERROR] Failed to execute goal org.basepom.maven:duplicate-finder-maven-plugin:1.4.0:check (default) on project adventureservService: Found duplicate classes/resources! -> [Help 1]
[WARNING]   org.pkl.core.ast.expression.unary.UnaryMinusNode
[WARNING]   org.pkl.core.ast.expression.unary.UnaryMinusNodeGen
[WARNING]   org.pkl.core.ast.frame.ReadAuxiliarySlotNode
[WARNING]   org.pkl.core.ast.frame.ReadEnclosingAuxiliarySlotNode
[WARNING]   org.pkl.core.ast.frame.ReadEnclosingFrameSlotNode
[WARNING]   org.pkl.core.ast.frame.ReadEnclosingFrameSlotNodeGen
[WARNING]   org.pkl.core.ast.frame.ReadFrameSlotNode
[WARNING]   org.pkl.core.ast.frame.ReadFrameSlotNodeGen
[WARNING]   org.pkl.core.ast.frame.WriteAuxiliarySlotNode
[WARNING]   org.pkl.core.ast.frame.WriteFrameSlotNode
[WARNING]   org.pkl.core.ast.frame.WriteFrameSlotNodeGen
[WARNING]   org.pkl.core.ast.internal.BlackholeNode
[WARNING]   org.pkl.core.ast.internal.BlackholeNodeGen
[WARNING]   org.pkl.core.ast.internal.GetBaseModuleClassNode
[WARNING]   org.pkl.core.ast.internal.GetClassNode
[WARNING]   org.pkl.core.ast.internal.GetClassNodeGen
[WARNING]   org.pkl.core.ast.internal.IsInstanceOfNode
[WARNING]   org.pkl.core.ast.internal.IsInstanceOfNodeGen
[WARNING]   org.pkl.core.ast.internal.ToStringNode
[WARNING]   org.pkl.core.ast.internal.ToStringNodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction0Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction0NodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction1Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction1NodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction2Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction2NodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction3Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction3NodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction4Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction4NodeGen
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction5Node
[WARNING]   org.pkl.core.ast.lambda.ApplyVmFunction5NodeGen
[WARNING]   org.pkl.core.ast.member.ClassMember
[WARNING]   org.pkl.core.ast.member.ClassMethod
[WARNING]   org.pkl.core.ast.member.ClassNode
[WARNING]   org.pkl.core.ast.member.ClassProperty
[WARNING]   org.pkl.core.ast.member.DefaultPropertyBodyNode
[WARNING]   org.pkl.core.ast.member.DelegateToExtraStorageMapOrParentNode
[WARNING]   org.pkl.core.ast.member.DelegateToExtraStorageObjNode
[WARNING]   org.pkl.core.ast.member.DelegateToExtraStorageObjOrParentNode
[WARNING]   org.pkl.core.ast.member.FunctionNode
[WARNING]   org.pkl.core.ast.member.Lambda
[WARNING]   org.pkl.core.ast.member.LocalTypedPropertyNode
[WARNING]   org.pkl.core.ast.member.Member
[WARNING]   org.pkl.core.ast.member.ModuleNode
[WARNING]   org.pkl.core.ast.member.ObjectMember
[WARNING]   org.pkl.core.ast.member.ObjectMethodNode
[WARNING]   org.pkl.core.ast.member.PropertyTypeNode
[WARNING]   org.pkl.core.ast.member.TypeAliasNode
[WARNING]   org.pkl.core.ast.member.TypeCheckedPropertyNode
[WARNING]   org.pkl.core.ast.member.TypeCheckedPropertyNodeGen
[WARNING]   org.pkl.core.ast.member.TypedPropertyNode
[WARNING]   org.pkl.core.ast.member.UnresolvedClassMemberNode
[WARNING]   org.pkl.core.ast.member.UnresolvedFunctionNode
[WARNING]   org.pkl.core.ast.member.UnresolvedMethodNode
[WARNING]   org.pkl.core.ast.member.UnresolvedPropertyNode
[WARNING]   org.pkl.core.ast.member.UntypedObjectMemberNode
[WARNING]   org.pkl.core.ast.repl.ResolveClassMemberNode
[WARNING]   org.pkl.core.ast.type.GetParentForTypeNode
[WARNING]   org.pkl.core.ast.type.IdentityMixinNode
[WARNING]   org.pkl.core.ast.type.ResolveDeclaredTypeNode
[WARNING]   org.pkl.core.ast.type.ResolveQualifiedDeclaredTypeNode
[WARNING]   org.pkl.core.ast.type.ResolveSimpleDeclaredTypeNode
[WARNING]   org.pkl.core.ast.type.TypeCastNode
[WARNING]   org.pkl.core.ast.type.TypeConstraintNode
[WARNING]   org.pkl.core.ast.type.TypeConstraintNodeGen
[WARNING]   org.pkl.core.ast.type.TypeNode
[WARNING]   org.pkl.core.ast.type.TypeNodeFactory
[WARNING]   org.pkl.core.ast.type.TypeTestNode
[WARNING]   org.pkl.core.ast.type.UnresolvedTypeNode
[WARNING]   org.pkl.core.ast.type.VmTypeMismatchException
[WARNING]   org.pkl.core.module.FileResolver
[WARNING]   org.pkl.core.module.ModuleKey
[WARNING]   org.pkl.core.module.ModuleKeyFactories
[WARNING]   org.pkl.core.module.ModuleKeyFactory
[WARNING]   org.pkl.core.module.ModuleKeys
[WARNING]   org.pkl.core.module.ModulePathResolver
[WARNING]   org.pkl.core.module.PathElement
[WARNING]   org.pkl.core.module.ProjectDependenciesManager
[WARNING]   org.pkl.core.module.ResolvedModuleKey
[WARNING]   org.pkl.core.module.ResolvedModuleKeys
[WARNING]   org.pkl.core.packages.Checksums
[WARNING]   org.pkl.core.packages.Dependency
[WARNING]   org.pkl.core.packages.DependencyMetadata
[WARNING]   org.pkl.core.packages.PackageAssetUri
[WARNING]   org.pkl.core.packages.PackageLoadError
[WARNING]   org.pkl.core.packages.PackageResolver
[WARNING]   org.pkl.core.packages.PackageResolvers
[WARNING]   org.pkl.core.packages.PackageUri
[WARNING]   org.pkl.core.packages.PackageUtils
[WARNING]   org.pkl.core.parser.ErrorStrategy
[WARNING]   org.pkl.core.parser.LexParseException
[WARNING]   org.pkl.core.parser.Lexer
[WARNING]   org.pkl.core.parser.Parser
[WARNING]   org.pkl.core.parser.antlr.PklLexer
[WARNING]   org.pkl.core.parser.antlr.PklParser
[WARNING]   org.pkl.core.parser.antlr.PklParserBaseVisitor
[WARNING]   org.pkl.core.parser.antlr.PklParserVisitor
[WARNING]   org.pkl.core.project.CanonicalPackageUri
[WARNING]   org.pkl.core.project.DeclaredDependencies
[WARNING]   org.pkl.core.project.Package
[WARNING]   org.pkl.core.project.Project
[WARNING]   org.pkl.core.project.ProjectDependenciesResolver
[WARNING]   org.pkl.core.project.ProjectDeps
[WARNING]   org.pkl.core.project.ProjectPackager
[WARNING]   org.pkl.core.repl.ReplRequest
[WARNING]   org.pkl.core.repl.ReplResponse
[WARNING]   org.pkl.core.repl.ReplServer
[WARNING]   org.pkl.core.resource.Resource
[WARNING]   org.pkl.core.resource.ResourceReader
[WARNING]   org.pkl.core.resource.ResourceReaders
[WARNING]   org.pkl.core.runtime.BaseModule
[WARNING]   org.pkl.core.runtime.BenchmarkModule
[WARNING]   org.pkl.core.runtime.CertificateUtils
[WARNING]   org.pkl.core.runtime.FileSystemManager
[WARNING]   org.pkl.core.runtime.Identifier
[WARNING]   org.pkl.core.runtime.Iterators
[WARNING]   org.pkl.core.runtime.JsonnetModule
[WARNING]   org.pkl.core.runtime.KeyLookupSuggestions
[WARNING]   org.pkl.core.runtime.LoggerImpl
[WARNING]   org.pkl.core.runtime.MathModule
[WARNING]   org.pkl.core.runtime.MemberLookupSuggestions
[WARNING]   org.pkl.core.runtime.MinPklVersionChecker
[WARNING]   org.pkl.core.runtime.MirrorFactories
[WARNING]   org.pkl.core.runtime.ModuleCache
[WARNING]   org.pkl.core.runtime.ModuleInfo
[WARNING]   org.pkl.core.runtime.ModuleResolver
[WARNING]   org.pkl.core.runtime.NullReceiverException
[WARNING]   org.pkl.core.runtime.PlatformModule
[WARNING]   org.pkl.core.runtime.ProjectModule
[WARNING]   org.pkl.core.runtime.ReaderBase
[WARNING]   org.pkl.core.runtime.ReflectModule
[WARNING]   org.pkl.core.runtime.ReleaseModule
[WARNING]   org.pkl.core.runtime.ResourceManager
[WARNING]   org.pkl.core.runtime.SemVerModule
[WARNING]   org.pkl.core.runtime.SettingsModule
[WARNING]   org.pkl.core.runtime.StackTraceGenerator
[WARNING]   org.pkl.core.runtime.StackTraceRenderer
[WARNING]   org.pkl.core.runtime.StdLibModule
[WARNING]   org.pkl.core.runtime.TestModule
[WARNING]   org.pkl.core.runtime.TestResults
[WARNING]   org.pkl.core.runtime.TestRunner
[WARNING]   org.pkl.core.runtime.VmBugException
[WARNING]   org.pkl.core.runtime.VmClass
[WARNING]   org.pkl.core.runtime.VmCollection
[WARNING]   org.pkl.core.runtime.VmContext
[WARNING]   org.pkl.core.runtime.VmDataSize
[WARNING]   org.pkl.core.runtime.VmDuration
[WARNING]   org.pkl.core.runtime.VmDynamic
[WARNING]   org.pkl.core.runtime.VmEvalException
[WARNING]   org.pkl.core.runtime.VmException
[WARNING]   org.pkl.core.runtime.VmExceptionBuilder
[WARNING]   org.pkl.core.runtime.VmExceptionRenderer
[WARNING]   org.pkl.core.runtime.VmFileDetector
[WARNING]   org.pkl.core.runtime.VmFunction
[WARNING]   org.pkl.core.runtime.VmIntSeq
[WARNING]   org.pkl.core.runtime.VmLanguage
[WARNING]   org.pkl.core.runtime.VmLanguageProvider
[WARNING]   org.pkl.core.runtime.VmList
[WARNING]   org.pkl.core.runtime.VmListing
[WARNING]   org.pkl.core.runtime.VmMap
[WARNING]   org.pkl.core.runtime.VmMapping
[WARNING]   org.pkl.core.runtime.VmNull
[WARNING]   org.pkl.core.runtime.VmObject
[WARNING]   org.pkl.core.runtime.VmObjectLike
[WARNING]   org.pkl.core.runtime.VmPair
[WARNING]   org.pkl.core.runtime.VmRegex
[WARNING]   org.pkl.core.runtime.VmSafeMath
[WARNING]   org.pkl.core.runtime.VmSet
[WARNING]   org.pkl.core.runtime.VmStackOverflowException
[WARNING]   org.pkl.core.runtime.VmTypeAlias
[WARNING]   org.pkl.core.runtime.VmTyped
[WARNING]   org.pkl.core.runtime.VmTypes
[WARNING]   org.pkl.core.runtime.VmTypesGen
[WARNING]   org.pkl.core.runtime.VmUndefinedValueException
[WARNING]   org.pkl.core.runtime.VmUtils
[WARNING]   org.pkl.core.runtime.VmValue
[WARNING]   org.pkl.core.runtime.VmValueConverter
[WARNING]   org.pkl.core.runtime.VmValueRenderer
[WARNING]   org.pkl.core.runtime.VmValueVisitor
[WARNING]   org.pkl.core.runtime.XmlModule
[WARNING]   org.pkl.core.service.ExecutorSpiImpl
[WARNING]   org.pkl.core.settings.PklSettings
[WARNING]   org.pkl.core.stdlib.AbstractRenderer
[WARNING]   org.pkl.core.stdlib.ExternalMemberNode
[WARNING]   org.pkl.core.stdlib.ExternalMethod0Node
[WARNING]   org.pkl.core.stdlib.ExternalMethod1Node
[WARNING]   org.pkl.core.stdlib.ExternalMethod2Node
[WARNING]   org.pkl.core.stdlib.ExternalMethod3Node
[WARNING]   org.pkl.core.stdlib.ExternalMethod4Node
[WARNING]   org.pkl.core.stdlib.ExternalMethod5Node
[WARNING]   org.pkl.core.stdlib.ExternalMethodNode
[WARNING]   org.pkl.core.stdlib.ExternalPropertyNode
[WARNING]   org.pkl.core.stdlib.LanguageAwareNode
[WARNING]   org.pkl.core.stdlib.PathConverterSupport
[WARNING]   org.pkl.core.stdlib.PathSpecParser
[WARNING]   org.pkl.core.stdlib.PklConverter
[WARNING]   org.pkl.core.stdlib.PklName
[WARNING]   org.pkl.core.stdlib.VmObjectFactories
[WARNING]   org.pkl.core.stdlib.VmObjectFactory
[WARNING]   org.pkl.core.stdlib.base.AnyNodes
[WARNING]   org.pkl.core.stdlib.base.AnyNodesFactory
[WARNING]   org.pkl.core.stdlib.base.BaseNodes
[WARNING]   org.pkl.core.stdlib.base.BaseNodesFactory
[WARNING]   org.pkl.core.stdlib.base.BooleanNodes
[WARNING]   org.pkl.core.stdlib.base.BooleanNodesFactory
[WARNING]   org.pkl.core.stdlib.base.ClassNodes
[WARNING]   org.pkl.core.stdlib.base.ClassNodesFactory
[WARNING]   org.pkl.core.stdlib.base.CollectionNodes
[WARNING]   org.pkl.core.stdlib.base.DataSizeNodes
[WARNING]   org.pkl.core.stdlib.base.DataSizeNodesFactory
[WARNING]   org.pkl.core.stdlib.base.DurationNodes
[WARNING]   org.pkl.core.stdlib.base.DurationNodesFactory
[WARNING]   org.pkl.core.stdlib.base.DynamicNodes
[WARNING]   org.pkl.core.stdlib.base.DynamicNodesFactory
[WARNING]   org.pkl.core.stdlib.base.FloatNodes
[WARNING]   org.pkl.core.stdlib.base.FloatNodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function0Nodes
[WARNING]   org.pkl.core.stdlib.base.Function0NodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function1Nodes
[WARNING]   org.pkl.core.stdlib.base.Function1NodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function2Nodes
[WARNING]   org.pkl.core.stdlib.base.Function2NodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function3Nodes
[WARNING]   org.pkl.core.stdlib.base.Function3NodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function4Nodes
[WARNING]   org.pkl.core.stdlib.base.Function4NodesFactory
[WARNING]   org.pkl.core.stdlib.base.Function5Nodes
[WARNING]   org.pkl.core.stdlib.base.Function5NodesFactory
[WARNING]   org.pkl.core.stdlib.base.FunctionNodes
[WARNING]   org.pkl.core.stdlib.base.FunctionNodesFactory
[WARNING]   org.pkl.core.stdlib.base.IntNodes
[WARNING]   org.pkl.core.stdlib.base.IntNodesFactory
[WARNING]   org.pkl.core.stdlib.base.IntSeqNodes
[WARNING]   org.pkl.core.stdlib.base.IntSeqNodesFactory
[WARNING]   org.pkl.core.stdlib.base.JsonRendererNodes
[WARNING]   org.pkl.core.stdlib.base.JsonRendererNodesFactory
[WARNING]   org.pkl.core.stdlib.base.ListNodes
[WARNING]   org.pkl.core.stdlib.base.ListNodesFactory
[WARNING]   org.pkl.core.stdlib.base.ListingNodes
[WARNING]   org.pkl.core.stdlib.base.ListingNodesFactory
[WARNING]   org.pkl.core.stdlib.base.MapNodes
[WARNING]   org.pkl.core.stdlib.base.MapNodesFactory
[WARNING]   org.pkl.core.stdlib.base.MappingNodes
[WARNING]   org.pkl.core.stdlib.base.MappingNodesFactory
[WARNING]   org.pkl.core.stdlib.base.MergeSort
[WARNING]   org.pkl.core.stdlib.base.ModuleClassNodes
[WARNING]   org.pkl.core.stdlib.base.ModuleClassNodesFactory
[WARNING]   org.pkl.core.stdlib.base.PListRendererNodes
[WARNING]   org.pkl.core.stdlib.base.PListRendererNodesFactory
[WARNING]   org.pkl.core.stdlib.base.PairNodes
[WARNING]   org.pkl.core.stdlib.base.PairNodesFactory
[WARNING]   org.pkl.core.stdlib.base.PcfRenderer
[WARNING]   org.pkl.core.stdlib.base.PcfRendererNodes
[WARNING]   org.pkl.core.stdlib.base.PcfRendererNodesFactory
[WARNING]   org.pkl.core.stdlib.base.PropertiesRendererNodes
[WARNING]   org.pkl.core.stdlib.base.PropertiesRendererNodesFactory
[WARNING]   org.pkl.core.stdlib.base.RegexMatchFactory
[WARNING]   org.pkl.core.stdlib.base.RegexNodes
[WARNING]   org.pkl.core.stdlib.base.RegexNodesFactory
[WARNING]   org.pkl.core.stdlib.base.ResourceNodes
[WARNING]   org.pkl.core.stdlib.base.ResourceNodesFactory
[WARNING]   org.pkl.core.stdlib.base.SetNodes
[WARNING]   org.pkl.core.stdlib.base.SetNodesFactory
[WARNING]   org.pkl.core.stdlib.base.StringNodes
[WARNING]   org.pkl.core.stdlib.base.StringNodesFactory
[WARNING]   org.pkl.core.stdlib.base.TypedNodes
[WARNING]   org.pkl.core.stdlib.base.TypedNodesFactory
[WARNING]   org.pkl.core.stdlib.base.YamlRendererNodes
[WARNING]   org.pkl.core.stdlib.base.YamlRendererNodesFactory
[WARNING]   org.pkl.core.stdlib.benchmark.BenchmarkUtils
[WARNING]   org.pkl.core.stdlib.benchmark.MicrobenchmarkNodes
[WARNING]   org.pkl.core.stdlib.benchmark.MicrobenchmarkNodesFactory
[WARNING]   org.pkl.core.stdlib.benchmark.OutputBenchmarkNodes
[WARNING]   org.pkl.core.stdlib.benchmark.OutputBenchmarkNodesFactory
[WARNING]   org.pkl.core.stdlib.benchmark.ParserBenchmarkNodes
[WARNING]   org.pkl.core.stdlib.benchmark.ParserBenchmarkNodesFactory
[WARNING]   org.pkl.core.stdlib.json.ParserNodes
[WARNING]   org.pkl.core.stdlib.json.ParserNodesFactory
[WARNING]   org.pkl.core.stdlib.jsonnet.RendererNodes
[WARNING]   org.pkl.core.stdlib.jsonnet.RendererNodesFactory
[WARNING]   org.pkl.core.stdlib.math.MathNodes
[WARNING]   org.pkl.core.stdlib.math.MathNodesFactory
[WARNING]   org.pkl.core.stdlib.platform.PlatformNodes
[WARNING]   org.pkl.core.stdlib.platform.PlatformNodesFactory
[WARNING]   org.pkl.core.stdlib.protobuf.RendererNodes
[WARNING]   org.pkl.core.stdlib.protobuf.RendererNodesFactory
[WARNING]   org.pkl.core.stdlib.reflect.ClassNodes
[WARNING]   org.pkl.core.stdlib.reflect.ClassNodesFactory
[WARNING]   org.pkl.core.stdlib.reflect.DeclaredTypeNodes
[WARNING]   org.pkl.core.stdlib.reflect.DeclaredTypeNodesFactory
[WARNING]   org.pkl.core.stdlib.reflect.ReflectNodes
[WARNING]   org.pkl.core.stdlib.reflect.ReflectNodesFactory
[WARNING]   org.pkl.core.stdlib.reflect.TypeNodes
[WARNING]   org.pkl.core.stdlib.reflect.TypeNodesFactory
[WARNING]   org.pkl.core.stdlib.registry.BaseMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.BenchmarkMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.EmptyMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.ExternalMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.JsonMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.JsonnetMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.MathMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.MemberRegistryFactory
[WARNING]   org.pkl.core.stdlib.registry.PlatformMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.ProtobufMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.ReflectMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.ReleaseMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.TestMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.XmlMemberRegistry
[WARNING]   org.pkl.core.stdlib.registry.YamlMemberRegistry
[WARNING]   org.pkl.core.stdlib.release.ReleaseNodes
[WARNING]   org.pkl.core.stdlib.release.ReleaseNodesFactory
[WARNING]   org.pkl.core.stdlib.test.TestNodes
[WARNING]   org.pkl.core.stdlib.test.TestNodesFactory
[WARNING]   org.pkl.core.stdlib.test.report.JUnitReport
[WARNING]   org.pkl.core.stdlib.test.report.SimpleReport
[WARNING]   org.pkl.core.stdlib.test.report.TestReport
[WARNING]   org.pkl.core.stdlib.xml.RendererNodes
[WARNING]   org.pkl.core.stdlib.xml.RendererNodesFactory
[WARNING]   org.pkl.core.stdlib.yaml.ParserNodes
[WARNING]   org.pkl.core.stdlib.yaml.ParserNodesFactory
[WARNING]   org.pkl.core.util.AbstractCharEscaper
[WARNING]   org.pkl.core.util.ArrayCharEscaper
[WARNING]   org.pkl.core.util.ByteArrayUtils
[WARNING]   org.pkl.core.util.CodeGeneratorUtils
[WARNING]   org.pkl.core.util.CollectionUtils
[WARNING]   org.pkl.core.util.DurationUtils
[WARNING]   org.pkl.core.util.EconomicMaps
[WARNING]   org.pkl.core.util.EconomicSets
[WARNING]   org.pkl.core.util.ErrorMessages
[WARNING]   org.pkl.core.util.GlobResolver
[WARNING]   org.pkl.core.util.IoUtils
[WARNING]   org.pkl.core.util.LateInit
[WARNING]   org.pkl.core.util.MathUtils
[WARNING]   org.pkl.core.util.MutableBoolean
[WARNING]   org.pkl.core.util.MutableLong
[WARNING]   org.pkl.core.util.MutableReference
[WARNING]   org.pkl.core.util.Nonnull
[WARNING]   org.pkl.core.util.NonnullByDefault
[WARNING]   org.pkl.core.util.Nullable
[WARNING]   org.pkl.core.util.Pair
[WARNING]   org.pkl.core.util.StringBuilderWriter
[WARNING]   org.pkl.core.util.StringSimilarity
[WARNING]   org.pkl.core.util.StringUtils
[WARNING]   org.pkl.core.util.json.Json
[WARNING]   org.pkl.core.util.json.JsonEscaper
[WARNING]   org.pkl.core.util.json.JsonHandler
[WARNING]   org.pkl.core.util.json.JsonParser
[WARNING]   org.pkl.core.util.json.JsonWriter
[WARNING]   org.pkl.core.util.json.Location
[WARNING]   org.pkl.core.util.json.ParseException
[WARNING]   org.pkl.core.util.properties.PropertiesUtils
[WARNING]   org.pkl.core.util.xml.Xml10Validator
[WARNING]   org.pkl.core.util.xml.Xml11Validator
[WARNING]   org.pkl.core.util.xml.XmlValidator
[WARNING]   org.pkl.core.util.yaml.Yaml11Emitter
[WARNING]   org.pkl.core.util.yaml.Yaml12Emitter
[WARNING]   org.pkl.core.util.yaml.YamlCompatEmitter
[WARNING]   org.pkl.core.util.yaml.YamlEmitter
[WARNING]   org.pkl.core.util.yaml.YamlEscaper
[WARNING]   org.pkl.core.util.yaml.snake.Yaml11Resolver
[WARNING]   org.pkl.core.util.yaml.snake.Yaml12Resolver
[WARNING]   org.pkl.core.util.yaml.snake.YamlCompatEmitterResolver
[WARNING]   org.pkl.core.util.yaml.snake.YamlCompatParserResolver
[WARNING]   org.pkl.core.util.yaml.snake.YamlResolver
[WARNING]   org.pkl.core.util.yaml.snake.YamlUtils
[WARNING] Found duplicate classes/resources in runtime classpath.

The instructions in the pkl documentation isn't clear. Any help on this please ?

Have raised the same question in Stackoverflow as well https://stackoverflow.com/questions/78087435/how-to-use-apple-pkl-for-spring-boot-wit-maven

linux-china commented 9 months ago

My example:

            <!-- generate java code from pkl -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>org.pkl.codegen.java.Main</mainClass>
                    <arguments>
                        <argument>-o</argument>
                        <argument>src/main</argument>
                        <argument>--generate-getters</argument>
                        <argument>src/main/resources/PigeonConfig.pkl</argument>
                    </arguments>
                    <includePluginDependencies>true</includePluginDependencies>
                    <includeProjectDependencies>false</includeProjectDependencies>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.pkl-lang</groupId>
                        <artifactId>pkl-tools</artifactId>
                        <version>0.25.2</version>
                    </dependency>
                </dependencies>
            </plugin>
arundotin commented 9 months ago

@linux-china - I tried and moved up to one level - but the app is not working. I get NPE

Below is my pom.xml (i have added --generate-spring-boot argument also)

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>org.pkl.codegen.java.Main</mainClass>
                    <arguments>
                        <argument>-o</argument>
                        <argument>adventureservService/src/main/</argument>
                        <argument>--generate-getters</argument>
                        <argument>--generate-spring-boot</argument>
                        <argument>adventureservService/src/main/resources/AppConfig.pkl</argument>
                    </arguments>
                    <includePluginDependencies>true</includePluginDependencies>
                    <includeProjectDependencies>false</includeProjectDependencies>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.pkl-lang</groupId>
                        <artifactId>pkl-tools</artifactId>
                        <version>0.25.2</version>
                    </dependency>
                </dependencies>
            </plugin>

Below are the pkl files i have

AppConfig.pkl

module com.arun.adventures.flights.AppConfig

server: Server

class Server {
  endpoints: Listing<Endpoint>
}

class Endpoint {
  name: String
  port: UInt16
}

This is my application.pkl

amends "AppConfig.pkl"

server {
  endpoints {
    new {
      name = "endpoint1"
      port = 1234
    }
    new {
      name = "endpoint2"
      port = 5678
    }
  }
}

This is my generated class (if you notice Endpoint class doesn't have spring annotation)

import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import java.lang.StringBuilder;
import java.util.List;
import java.util.Objects;
import org.pkl.config.java.mapper.Named;
import org.pkl.config.java.mapper.NonNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;

@ConstructorBinding
@ConfigurationProperties
public final class AppConfig {
  private final @NonNull Server server;

  public AppConfig(@Named("server") @NonNull Server server) {
    this.server = server;
  }

  public @NonNull Server getServer() {
    return server;
  }

  public AppConfig withServer(@NonNull Server server) {
    return new AppConfig(server);
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (obj == null) return false;
    if (this.getClass() != obj.getClass()) return false;
    AppConfig other = (AppConfig) obj;
    if (!Objects.equals(this.server, other.server)) return false;
    return true;
  }

  @Override
  public int hashCode() {
    int result = 1;
    result = 31 * result + Objects.hashCode(this.server);
    return result;
  }

  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder(100);
    builder.append(AppConfig.class.getSimpleName()).append(" {");
    appendProperty(builder, "server", this.server);
    builder.append("\n}");
    return builder.toString();
  }

  private static void appendProperty(StringBuilder builder, String name, Object value) {
    builder.append("\n  ").append(name).append(" = ");
    String[] lines = Objects.toString(value).split("\n");
    builder.append(lines[0]);
    for (int i = 1; i < lines.length; i++) {
      builder.append("\n  ").append(lines[i]);
    }
  }

  @ConstructorBinding
  @ConfigurationProperties("server")
  public static final class Server {
    private final @NonNull List<@NonNull Endpoint> endpoints;

    public Server(@Named("endpoints") @NonNull List<@NonNull Endpoint> endpoints) {
      this.endpoints = endpoints;
    }

    public @NonNull List<@NonNull Endpoint> getEndpoints() {
      return endpoints;
    }

    public Server withEndpoints(@NonNull List<@NonNull Endpoint> endpoints) {
      return new Server(endpoints);
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (this.getClass() != obj.getClass()) return false;
      Server other = (Server) obj;
      if (!Objects.equals(this.endpoints, other.endpoints)) return false;
      return true;
    }

    @Override
    public int hashCode() {
      int result = 1;
      result = 31 * result + Objects.hashCode(this.endpoints);
      return result;
    }

    @Override
    public String toString() {
      StringBuilder builder = new StringBuilder(100);
      builder.append(Server.class.getSimpleName()).append(" {");
      appendProperty(builder, "endpoints", this.endpoints);
      builder.append("\n}");
      return builder.toString();
    }
  }

  @ConstructorBinding
  public static final class Endpoint {
    private final @NonNull String name;

    private final int port;

    public Endpoint(@Named("name") @NonNull String name, @Named("port") int port) {
      this.name = name;
      this.port = port;
    }

    public @NonNull String getName() {
      return name;
    }

    public Endpoint withName(@NonNull String name) {
      return new Endpoint(name, port);
    }

    public int getPort() {
      return port;
    }

    public Endpoint withPort(int port) {
      return new Endpoint(name, port);
    }

    @Override
    public boolean equals(Object obj) {
      if (this == obj) return true;
      if (obj == null) return false;
      if (this.getClass() != obj.getClass()) return false;
      Endpoint other = (Endpoint) obj;
      if (!Objects.equals(this.name, other.name)) return false;
      if (!Objects.equals(this.port, other.port)) return false;
      return true;
    }

    @Override
    public int hashCode() {
      int result = 1;
      result = 31 * result + Objects.hashCode(this.name);
      result = 31 * result + Objects.hashCode(this.port);
      return result;
    }

    @Override
    public String toString() {
      StringBuilder builder = new StringBuilder(150);
      builder.append(Endpoint.class.getSimpleName()).append(" {");
      appendProperty(builder, "name", this.name);
      appendProperty(builder, "port", this.port);
      builder.append("\n}");
      return builder.toString();
    }
  }
}

This is my FlightsService.java

@Service
public class FlightsService {

    private final AppConfig.Server server;

    public FlightsService(AppConfig.Server server) {
        this.server = server;
    }

    public AppConfig.Server getServer() {
        return server;
    }

}

From my controller when i do System.out.println(flightsService.getServer());

This is the output i get

Server {
  endpoints = null
}