How to create a pom.xml file with Gradle using variables? - java

I want to write a Gradle function, which creates a pom.xml file with data (groupId, artifactId, version) passed as arguments.
I created following script:
apply plugin: 'maven'
apply plugin: 'java'
def createMainPom(mainDir, groupId, artifactId, version)
{
pom
{
project
{
groupId '$groupId' // Error
artifactId '$artifactId'
version '$version'
packaging 'pom'
name 'New app'
modules
{
module
{
name 'app'
}
module
{
name 'integration-tests'
}
}
}
}.writeTo('$mainDir/pom.xml');
}
[...]
When I run it, I get the error at the position marked with // Error above:
> No signature of method: java.lang.String.call() is applicable for argument typ
es: (java.lang.String) values: [a]
Possible solutions: wait(), any(), wait(long), split(java.lang.String), find(jav
a.lang.String), count(java.lang.String)
How can I fix this?

The plugin documentation states:
Note: groupId, artifactId, version, and packaging should always be set directly on the pom object.
Does moving those properties up a level, out of project, make a difference?

For strings variables resolution use double quotes:
groupId "$groupId"
artifactId "$artifactId"
version "$version"
...
}.writeTo("$mainDir/pom.xml");

Related

cxf-codegen-plugin in Gradle classpath in jax-ws-catalog.xml

Firstly idea was to generate java classes without internet connection, so I decided use jax-ws-catalog.xml file to rewrite uri on resource/local directory.
I defined location of xsd files by using jax-ws-catalog.xml with classpath.
But every compilation is wrong and catching error:
WARN org.apache.cxf.resource.URIResolver - Resource classpath:/local/xml.xsd was not found in the classloaders.
WSDLToJava Error: org.apache.ws.commons.schema.XmlSchemaException: Unable to locate imported document at 'http://www.w3.org/2001/xml.xsd', relative to ...{my file}...
build.gradle
plugins {
id 'java'
id 'java-library'
id "io.mateo.cxf-codegen" version "1.0.2"
}
import io.mateo.cxf.codegen.wsdl2java.Wsdl2Java
ext {
artifactId = 'soap-adapter'
}
jar {
enabled = true
}
bootJar {
enabled = false
}
dependencies {
implementation "javax.xml.ws:jaxws-api:${jaxwsApiVersion}"
implementation "javax.jws:javax.jws-api:${javaxJwsApiVersion}"
implementation "com.sun.xml.messaging.saaj:saaj-impl:${sunSaajImplVersion}"
implementation "org.apache.cxf:cxf-rt-frontend-jaxws:${apacheCxfVersion}"
implementation "org.apache.cxf:cxf-rt-transports-http:${apacheCxfVersion}"
implementation "org.apache.cxf:cxf-rt-ws-security:${apacheCxfVersion}"
cxfCodegen "jakarta.xml.ws:jakarta.xml.ws-api"
cxfCodegen "jakarta.annotation:jakarta.annotation-api"
cxfCodegen "ch.qos.logback:logback-classic"
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
// Common properties of java generation from wsdl.
tasks.withType(Wsdl2Java).configureEach {
toolOptions {
markGenerated.set(true)
outputDir.set(file("${buildDir}/generated"))
addToMainSourceSet.set(true)
wsdl.set(file("${projectDir}/src/main/resources/wsdl/myWsdl.wsdl"))
catalog.set("${projectDir}/src/main/resources/META-INF/jax-ws-catalog.xml")
}
}
compileJava.dependsOn wsdl2java
jax-ws-catalog.xml
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI uriStartString="http://www.w3.org/2001/xml.xsd" rewritePrefix="classpath:/local/xml.xsd"/>
</catalog>
I think that classpath is determined wrong.
I discovered the next:
At the programm compilation jax-ws-catalog.xml using only relative paths from itself.
At the runtime you can use classpath.
And jax-ws library using resurce/META-INF/jax-ws-catalog.xml by default.
So I just duplicated this jax-ws-catalog.xml into next directories with different properties:
resource/jax-ws-catalog.xml
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<rewriteURI uriStartString="http://" rewritePrefix="local/"/>
<rewriteURI uriStartString="https://" rewritePrefix="local/"/>
</catalog>
resource/META-INF/jax-ws-catalog.xml
<?xml version="1.0"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<rewriteSystem systemIdStartString="http://www.w3.org/2006/03/addressing" rewritePrefix="classpath:local/www.w3.org/2006/03/addressing"/>
<rewriteSystem systemIdStartString="http://www.w3.org/2005/08/addressing" rewritePrefix="classpath:local/www.w3.org/2005/08/addressing"/>
</catalog>
In build.gradle I changed the next
tasks.withType(Wsdl2Java).configureEach {
toolOptions {
markGenerated.set(true)
outputDir.set(file("${buildDir}/generated"))
addToMainSourceSet.set(true)
wsdl.set(file("${projectDir}/src/main/resources/wsdl/myWsdl.wsdl"))
catalog.set("${projectDir}/src/main/resources/jax-ws-catalog.xml")
}
}

java.lang.NoSuchMethodError | Spring

I am trying to connect to a database using Spring. Unfortunately, it always gives me the error message, can that it could not find a certain method.
Incidental information that may not hurt. The program is complied with Java 8 . Accordingly, the server also runs on Java 8
Thanks for the help!
Error
build.gradle:
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
}
group = 'io.github.rysefoxx'
version = '1.0-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://repo.codemc.org/repository/maven-public/"
}
}
dependencies {
compileOnly files('lib/spigot.jar')
compileOnly 'org.projectlombok:lombok:1.18.24'
implementation 'io.github.rysefoxx:RyseInventory-Plugin:1.1.9-SNAPSHOT'
implementation 'io.github.rysefoxx:Hologram:1.0-SNAPSHOT'
implementation 'net.wesjd:anvilgui:1.5.3-SNAPSHOT'
implementation 'org.hibernate:hibernate-core:5.6.5.Final'
implementation 'org.hibernate:hibernate-envers:5.6.5.Final'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.6.7'
implementation 'org.springframework.boot:spring-boot-starter-cache:2.6.7'
implementation 'org.springframework:spring-aspects:5.3.19'
implementation 'mysql:mysql-connector-java:8.0.28'
implementation 'org.reflections:reflections:0.10.2'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.2'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
}
shadowJar {
mergeServiceFiles()
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
spring.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/home
spring.datasource.jdbc-url=jdbc:mysql://localhost:3306/home
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
spring.jpa.database=MYSQL
spring.jpa.hibernate.ddl-auto=none
hibernate.hbm2ddl.auto=none
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=false
spring.datasource.initialization-mode=always
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
spring.factories:
org.springframework.data.repository.core.support.RepositoryFactorySupport=org.springframework.data.jpa.repository.support.JpaRepositoryFactory
org.springframework.data.util.ProxyUtils$ProxyDetector=org.springframework.data.jpa.util.HibernateProxyDetector
# Initializers
org.springframework.context.ApplicationContextInitializer=\
org.springframework.boot.autoconfigure.SharedMetadataReaderFactoryContextInitializer,\
org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener,\
org.springframework.boot.context.ConfigurationWarningsApplicationContextInitializer,\
org.springframework.boot.context.ContextIdApplicationContextInitializer,\
org.springframework.boot.context.config.DelegatingApplicationContextInitializer,\
org.springframework.boot.rsocket.context.RSocketPortInfoApplicationContextInitializer,\
org.springframework.boot.web.context.ServerPortInfoApplicationContextInitializer
# Application Listeners
org.springframework.context.ApplicationListener=\
org.springframework.boot.autoconfigure.BackgroundPreinitializer,\
org.springframework.boot.ClearCachesApplicationListener,\
org.springframework.boot.builder.ParentContextCloserApplicationListener,\
org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor,\
org.springframework.boot.context.FileEncodingApplicationListener,\
org.springframework.boot.context.config.AnsiOutputApplicationListener,\
org.springframework.boot.context.config.ConfigFileApplicationListener,\
org.springframework.boot.context.config.DelegatingApplicationListener,\
org.springframework.boot.context.logging.ClasspathLoggingApplicationListener,\
org.springframework.boot.context.logging.LoggingApplicationListener,\
org.springframework.boot.liquibase.LiquibaseServiceLocatorApplicationListener
# Auto Configuration Import Listeners
org.springframework.boot.autoconfigure.AutoConfigurationImportListener=\
org.springframework.boot.autoconfigure.condition.ConditionEvaluationReportAutoConfigurationImportListener
# Auto Configuration Import Filters
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
org.springframework.boot.autoconfigure.condition.OnBeanCondition,\
org.springframework.boot.autoconfigure.condition.OnClassCondition,\
org.springframework.boot.autoconfigure.condition.OnWebApplicationCondition
# Auto Configure
org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.github.rysefoxx.spring.SpringSpigotAutoConfiguration,\
org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration,\
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration,\
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration,\
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration,\
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration,\
org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration,\
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration,\
org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration,\
org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveDataAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraReactiveRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.cassandra.CassandraRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration,\
org.springframework.boot.autoconfigure.hazelcast.HazelcastJpaDependencyAutoConfiguration,\
org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration,\
org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration,\
org.springframework.boot.autoconfigure.integration.IntegrationAutoConfiguration,\
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.XADataSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration,\
org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration,\
org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration,\
org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration,\
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration,\
org.springframework.boot.autoconfigure.rsocket.RSocketMessagingAutoConfiguration,\
org.springframework.boot.autoconfigure.rsocket.RSocketRequesterAutoConfiguration,\
org.springframework.boot.autoconfigure.rsocket.RSocketServerAutoConfiguration,\
org.springframework.boot.autoconfigure.rsocket.RSocketStrategiesAutoConfiguration,\
org.springframework.boot.autoconfigure.security.rsocket.RSocketSecurityAutoConfiguration,\
org.springframework.boot.autoconfigure.sendgrid.SendGridAutoConfiguration,\
org.springframework.boot.autoconfigure.session.SessionAutoConfiguration,\
org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration,\
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration,\
org.springframework.boot.autoconfigure.transaction.jta.JtaAutoConfiguration,\
org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration
# Failure analyzers
org.springframework.boot.diagnostics.FailureAnalyzer=\
org.springframework.boot.autoconfigure.data.redis.RedisUrlSyntaxFailureAnalyzer,\
org.springframework.boot.autoconfigure.diagnostics.analyzer.NoSuchBeanDefinitionFailureAnalyzer,\
org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingFailureAnalyzer,\
org.springframework.boot.autoconfigure.jdbc.DataSourceBeanCreationFailureAnalyzer,\
org.springframework.boot.autoconfigure.jdbc.HikariDriverConfigurationFailureAnalyzer,\
org.springframework.boot.autoconfigure.session.NonUniqueSessionRepositoryFailureAnalyzer,\
org.springframework.boot.context.properties.NotConstructorBoundInjectionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanCurrentlyInCreationFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanDefinitionOverrideFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BeanNotOfRequiredTypeFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BindFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.BindValidationFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.UnboundConfigurationPropertyFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.ConnectorStartFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.NoUniqueBeanDefinitionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.PortInUseFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.ValidationExceptionFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyNameFailureAnalyzer,\
org.springframework.boot.diagnostics.analyzer.InvalidConfigurationPropertyValueFailureAnalyzer
# Temcensored availability providers
org.springframework.boot.autoconfigure.temcensored.TemcensoredAvailabilityProvider=\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemcensoredAvailabilityProvider,\
org.springframework.boot.autoconfigure.mustache.MustacheTemcensoredAvailabilityProvider,\
org.springframework.boot.autoconfigure.groovy.temcensored.GroovyTemcensoredAvailabilityProvider,\
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemcensoredAvailabilityProvider
# PropertySource Loaders
org.springframework.boot.env.PropertySourceLoader=\
org.springframework.boot.env.PropertiesPropertySourceLoader,\
org.springframework.boot.env.YamlPropertySourceLoader
# Run Listeners
org.springframework.boot.SpringApplicationRunListener=\
org.springframework.boot.context.event.EventPublishingRunListener
# Error Reporters
org.springframework.boot.SpringBootExceptionReporter=\
org.springframework.boot.diagnostics.FailureAnalyzers
# Environment Post Processors
org.springframework.boot.env.EnvironmentPostProcessor=\
org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor,\
org.springframework.boot.env.SpringApplicationJsonEnvironmentPostProcessor,\
org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor,\
org.springframework.boot.reactor.DebugAgentEnvironmentPostProcessor
# FailureAnalysisReporters
org.springframework.boot.diagnostics.FailureAnalysisReporter=\
org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter
org.springframework.beans.BeanInfoFactory=org.springframework.beans.ExtendedBeanInfoFactory
It's not unlikely to be a problem caused by the Shadow Plugin, it has a hurdle: You have to tell it how to handle file collisions, i.e. files with the same name. While this is not hard, and you already did it partially ( mergeServiceFiles()), I use it with Gradle Kotlin DSL like:
tasks.withType<ShadowJar> {
mergeServiceFiles()
append("META-INF/spring.handlers")
append("META-INF/spring.schemas")
append("META-INF/spring.tooling")
transform(
PropertiesFileTransformer().apply {
paths = mutableListOf("META-INF/spring.factories")
mergeStrategy = "append"
})
}
It doesn't tell in its current version when such a conflict occurs, so you have to waste big amounts of time finding the conflicts yourself. But there is a pull request that it tells if there is a collision: https://github.com/johnrengelman/shadow/pull/773.
Until the pull request gets merged you could use the forked branch to be always informed about file collisions: https://github.com/JD-CSTx/shadow/tree/chapmajs-collision_logging.
Maybe I'm guessing wrong, and your problem is caused by something else, but this looks definitely like it could come from file collisions.

Publishing is not able to resolve a dependency on a project with multiple publications that have different coordi nates

I intend to publish my modules in a nexus repository with the following steps.
first step:
Create a android-publications.gradle file and add the following contents to it
android-publications.gradle :
apply plugin: 'maven-publish'
ext.moduleVersion = "0.0.0"
def moduleGroupId = "team.techvida.framework"
def moduleRepoUrl = "http://url/repository/maven-releases/"
afterEvaluate {
publishing {
publications {
debug(MavenPublication) {
from components.debug
groupId = moduleGroupId
artifactId = "$project.name-debug"
version = moduleVersion
}
release(MavenPublication) {
from components.release
groupId = moduleGroupId
artifactId = project.name
version = moduleVersion
}
}
repositories {
maven {
name "nexus"
url moduleRepoUrl
allowInsecureProtocol = true
credentials {
username findProperty("nexusUsername")
password findProperty("nexusPassword")
}
}
}
}
}
Step two
Use it in all modules as follows:
core module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
}
presentation module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
}
Third step
Use in a module that uses other modules
di module =>
apply from: "$rootDir/android-library-build.gradle"
apply from: "$rootDir/buildSrc/android-publications.gradle"
ext.moduleVersion = "0.0.1"
dependencies {
implementation(project(Modules.core))
implementation(project(Modules.imageLoading))
implementation(project(Modules.prettyLogger))
}
Note 1 : Publishing the second step modules is done successfully.
Step 4 (which leads to a compilation error)
Publish the third step module (di)
Received error:
What went wrong:
Could not determine the dependencies of task ':di:publishReleasePublicationToNexusRepository'.
> Publishing is not able to resolve a dependency on a project with multiple publications that have different coordi
nates.
Found the following publications in project ':image_loading':
- Maven publication 'debug' with coordinates team.techvida.framework:image_loading-debug:0.0.1
- Maven publication 'release' with coordinates team.techvida.framework:image_loading:0.0.1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run
with --scan to get full insights.
Would you please tell me how to solve this problem?

Gradle: how to declare a dependency to a specific configuration of a project programatically in java

Following the setup described in Simple sharing of artifacts between projects, we are in the special case where we have a multi module gradle build that produce different types of jars and we would like to declare a dependency to those jar in a configuration.
dependencies {
instrumentedClasspath(project(path: ":producer", configuration: 'instrumentedJars'))
}
from the docs works great.
In the project dependency-tests I have a project that reproduce the setup (with different names, but the idea is the same).
But I am doing this in a Gradle-plugin and I would like to have the same declaration in java.
DependencyHandler dependencyHandler = project.getDependencies();
// this adds a dependency to the main jar of the 'producer' project:
dependencyHandler.add("instrumentedClasspath", project.getRootProject().findProject(":producer"));
// this is not working:
dependencyHandler.add("instrumentedClasspath", project.getRootProject().findProject(":producer").getConfigurations().getByName("instrumentedJars"));
Failing with:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':printConf'.
> Could not resolve all dependencies for configuration ':instrumentedJars'.
> Cannot convert the provided notation to an object of type Dependency: configuration ':producer:instrumentedJars' artifacts.
The following types/formats are supported:
- Instances of Dependency.
- String or CharSequence values, for example 'org.gradle:gradle-core:1.0'.
- Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0'].
- FileCollections, for example files('some.jar', 'someOther.jar').
- Projects, for example project(':some:project:path').
- ClassPathNotation, for example gradleApi().
Comprehensive documentation on dependency notations is available in DSL reference for DependencyHandler type.
* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
project(...)
inside the dependencies block comes from the DependencyHandler, and
path: ":producer", configuration: 'instrumentedJars'
is actually a map {"path"=":producer", "configuration"="instrumentedJars"}.
So something like that should work in Java:
Map<String, String> map = new HashMap<>();
map.put("path", ":producer");
map.put("configuration", "instrumentedJars");
dependencyHandler.add("instrumentedClasspath", dependencyHandler.project(map));
Note: When using Kotlin build script you can easily see types and declarations of functions and might be easier for discovering API. So in Kotlin project(...) in the dependencies block is an extension method defined as:
fun DependencyHandler.project(
path: String,
configuration: String? = null
): ProjectDependency =
uncheckedCast(
project(
if (configuration != null) mapOf("path" to path, "configuration" to configuration)
else mapOf("path" to path)
)
)

upgrading gradle to 6.x error Could not set unknown property 'testClassesDir' for task ':systemtestRun' of type org.gradle.api.tasks.testing.Test

I’m updating the gradle version of my application, it was with version 2.3 and I’m going to 6.7.1
I changed some things, of course, but this error I’m not able to resolve:
> Could not set unknown property 'testClassesDir' for task ':systemtestRun' of type org.gradle.api.tasks.testing.Test.
build.gradle:
task systemtestRun(type: Test) {
description 'run tests'
testClassesDir = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath + sourceSets.test.runtimeClasspath }
It should be testClassesDirs not testClassesDir:
tasks.register('systemtestRun', Test) {
description = 'Runs system tests.'
group = 'verification'
testClassesDirs = sourceSets.systemtest.output.classesDirs
classpath = sourceSets.systemtest.runtimeClasspath
}

Categories

Resources