Jaxb2 plugin in kotlin gradle

Hi,

I am trying to develop soap web services using Gradle with kotlin. But I am unable to get gradle jaxb2 plugin. I tried using gradle mentioned in spring.io site but getting issues in build.gradle.kts. Can anyone reply with gradle with kotlin exact plugin that performs same as maven plugin mention below.

Maven plugin:

<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>jaxb2-maven-plugin</artifactId>
				<version>1.6</version>
				<executions>
					<execution>
						<id>xjc</id>
						<goals>
							<goal>xjc</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<schemaDirectory>src/main/resources</schemaDirectory>
					<outputDirectory>src/main/java</outputDirectory>
					<clearOutputDir>false</clearOutputDir>
				</configuration>
			</plugin>

I need the same in Gradle Plugin in kotlin

Regards,

The equivalent of a Maven plugin is a Gradle Plugin.
Kotlin can interoperate transparently with Java classes, so you may search per a Jaxb Gradle Plugin to generate Java classes as well.

Try this one: GitHub - GradleUp/jaxb2

Hi, Thanks for the response. I am new to Gradle and this is my first project. I have used the same but getting some issues,

For Request-Classes - Expression ‘‘request-classes’’ of type ‘Char’ cannot be invoked as a function. The function ‘invoke()’ is not found
Too many characters in a character literal ‘‘request-classes’’

basePackage: Unresolved reference: basePackage
schema: Unresolved reference: schema

jaxb2 issue

Oh well, what’s happening is that the example shown is in Groovy, while your build script is in Kotlin.

Gradle script files can be written in either Groovy or Kotlin. The syntax is somehow similar but Groovy is not really easy to understand since it heavily uses metaprogramming and when simply calling "request-classes" in reality at runtime it will be called create("request-classes") where create() is a method from NamedDomainObjectContainer.

As a beginner, understanding the intricate mechanisms of Gradle is no easy task, especially when dealing with Groovy. The official Gradle Documentation is really well written and covers the migration of code from Groovy to Kotlin. I’d recommend to start there. The contents may overwhelm you, just take your time and search in the documentation the other concepts that may seems strange to you.