JUnitException: TestEngine with ID 'spock' failed to discover tests - build.gradle

We are attempting to make some updates to our testing suite. We would like to convert our contract tests that use PACT to use jUnit5.
When we update our packages such as our PACT consumer/provider and attempt to run the code we get this exception :
org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 8.
...
Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'spock' failed to discover tests
The current build.gradle file contains
plugins {
id 'java'
id 'groovy'
id "au.com.dius.pact" version '4.2.13'
}
dependencies {
testImplementation 'org.codehaus.groovy:groovy:3.0.12'
testImplementation group: 'au.com.dius.pact.consumer', name: 'junit5', version: '4.3.4'
testImplementation group: 'au.com.dius.pact.provider', name: 'junit5', version: '4.3.4'
testImplementation 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
testImplementation 'com.motorolasolutions.pnf:utils:1.0.+:test-lib'
testImplementation "org.spockframework:spock-core:2.1-M2-groovy-3.0"
testImplementation "org.spockframework:spock-spring:2.1-M2-groovy-3.0"
testImplementation "org.spockframework:spock-core:2.1-M2-groovy-3.0"
testImplementation('com.athaydes:spock-reports:2.1.1-groovy-3.0') {
transitive = false
}
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.9.1'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.9.1'
}
We have tried messing with the plugin Id for 'groovy' and 'java' without luck. Does anyone have any recommendations on this issue?
Thanks

Related

How to run Karate and Gatling with Gradle build system for performance testing

I'm trying to run a Karate test as a Gatling performance test. I am being use Gradle however. When trying to run under Gradle the below disaster unfolds.
Appreciate any ideas what might be causing KarateAction to crash.
i have added Gatling dependencies in gradle build
BUILD GRADLE:
plugins {
// id 'org.springframework.boot' version '2.5.5'
// id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'net.researchgate.release' version '2.8.1'
}
group 'org.ikano'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
ext {
cucumberVersion = "5.7.0"
karateVersion = '1.1.0'
// kafkaProducer = "3.2.0"
// kafkaConsumer = "3.2.0"
// kafkaCommonModel = "3.2.0"
dbUtilsVersion = "1.7"
}
apply plugin: 'scala'
configurations {
gatling
}
sourceSets {
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
exclude '**/*.scala'
}
}
}
test {
useJUnitPlatform()
systemProperty "karate.options", System.properties.getProperty("karate.options")
systemProperty "karate.env", System.properties.getProperty("karate.env")
outputs.upToDateWhen { false }
}
repositories {
maven {
url "https://artifacts.le.tnt.bank.*****/repository/maven-****"
credentials {
username '*******'
password '**********'
}
mavenCentral()
}
}
task karateDebug(type: JavaExec) {
classpath = sourceSets.test.runtimeClasspath
main = 'com.intuit.karate.cli.Main'
}
dependencies {
implementation("commons-configuration:commons-configuration:1.10")
implementation("org.json:json:20180813")
implementation("javax.mail:mail:1.5.0-b01")
implementation("com.jayway.jsonpath:json-path:2.6.0")
implementation("com.googlecode.json-simple:json-simple:1.1.1")
// implementation("org.springframework:spring-context:5.3.13")
implementation("org.apache.poi:poi-ooxml:4.1.1")
// implementation("org.springframework:spring-webmvc:4.3.0.RELEASE")
testImplementation("com.intuit.karate:karate-core:1.2.0")
testImplementation("junit:junit:4.13.2")
testImplementation("com.intuit.karate:karate-junit5:1.1.0")
testImplementation("com.intuit.karate:karate-gatling:1.1.0")
testImplementation("com.intuit.karate:karate-apache:0.9.6")
testImplementation("net.masterthought:cucumber-reporting:3.8.0")
testImplementation("hu.blackbelt.bundles.poi:org.apache.poi:4.1.2_2")
testImplementation("org.apache.poi:poi:4.1.1")
testImplementation("io.rest-assured:rest-assured:4.3.0")
testCompile 'com.intuit.karate:karate-junit5:1.1.0'
testCompile "com.intuit.karate:karate-gatling:${karateVersion}"
// compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '2.5.5', ext: 'pom'
//implementation group: 'org.springframework', name: 'spring-websocket', version: '5.2.9.RELEASE'
//implementation group: 'org.springframework', name: 'spring-messaging', version: '5.2.9.RELEASE'
// implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'org.springframework.boot:spring-boot-starter'
// testImplementation('org.springframework.boot:spring-boot-starter-test')
//{exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'}
compile group: 'joda-time', name: 'joda-time', version: '2.10.6'
// implementation "com.ikano.ipay.eem.kafka:kafka-producer:${kafkaProducer}"
// implementation "com.ikano.ipay.eem.kafka:kafka-consumer:${kafkaConsumer}"
// implementation "com.ikano.ipay.eem.kafka:kafka-common-model:${kafkaCommonModel}"
implementation group: 'redis.clients', name: 'jedis', version: '2.9.0'
implementation group: 'org.redisson', name: 'redisson', version: "3.16.3"
compile group: 'org.apache.poi', name: 'poi', version: '4.1.2'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
compile group: 'commons-dbutils', name: 'commons-dbutils', version: "$dbUtilsVersion"
task gatlingRun(type: JavaExec) {
group = 'Web Tests'
description = 'Run Gatling Tests'
new File("${buildDir}/reports/gatling").mkdirs()
classpath = sourceSets.test.runtimeClasspath
main = "io.gatling.app.Gatling"
args = [
// change this to suit your simulation entry-point
'-s', 'performance2.userSimulation',
'-rf', "${buildDir}/reports/gatling"
]
systemProperties System.properties
}
group = "org.ikano"
version = "1.0-SNAPSHOT"
description = "IPay"
java.sourceCompatibility = JavaVersion.VERSION_1_8
FOR SCALA
package performance
import com.intuit.karate.gatling.PreDef._
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import scala.concurrent.duration._
class UserSimulation extends Simulation{
val getSingleUser: ScenarioBuilder = scenario("UK Onboarding - Verify user is able to onboard successfully").exec(karateFeature("classpath:performance/onboarding.feature"))
setUp(
getSingleUser.inject(rampUsers(10).during(5 seconds))
)
}
Command Line :gradle gatlingRun
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :gatlingRun
16:10:18.039 [main] INFO i.g.c.config.GatlingConfiguration$ - Gatling will try to use 'gatling.conf' as config file.
16:10:20.052 [GatlingSystem-akka.actor.default-dispatcher-6] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
16:10:22.818 [main] ERROR io.gatling.app.Gatling$ - Run crashed
java.lang.IllegalArgumentException: User defined Simulation class performance2.userSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
at io.gatling.app.Selection$.apply(Selection.scala:36)
at io.gatling.app.Runner.run0(Runner.scala:61)
at io.gatling.app.Runner.run(Runner.scala:49)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance2.userSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
... 15 common frames omitted
Exception in thread "main" java.lang.IllegalArgumentException: User defined Simulation class performance2.userSimulation could not be loaded
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:80)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$4(Selection.scala:85)
at scala.Option.orElse(Option.scala:477)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$3(Selection.scala:85)
at scala.Option.flatMap(Option.scala:283)
at io.gatling.app.Selection$Selector.singleSimulationFromConfig(Selection.scala:83)
at io.gatling.app.Selection$Selector.$anonfun$selection$1(Selection.scala:52)
at scala.Option.getOrElse(Option.scala:201)
at io.gatling.app.Selection$Selector.selection(Selection.scala:44)
at io.gatling.app.Selection$.apply(Selection.scala:36)
at io.gatling.app.Runner.run0(Runner.scala:61)
at io.gatling.app.Runner.run(Runner.scala:49)
at io.gatling.app.Gatling$.start(Gatling.scala:83)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
Caused by: java.lang.ClassNotFoundException: performance2.userSimulation
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at io.gatling.app.Selection$Selector.$anonfun$singleSimulationFromConfig$2(Selection.scala:71)
at scala.util.Try$.apply(Try.scala:210)
at io.gatling.app.Selection$Selector.findUserDefinedSimulationInClassloader$1(Selection.scala:71)
... 15 more
> Task :gatlingRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':gatlingRun'.
> Process 'command 'C:\Program Files\Amazon Corretto\jdk1.8.0_282\bin\java.exe'' finished with non-zero exit value 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.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 44s
3 actionable tasks: 1 executed, 2 up-to-date
The package name is performance but inside the log it says:
performance2.userSimulation
Can you change it to in the run command:
performance.userSimulation
I think that is the issue you are facing. It cant find the simulation class.

Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

My application runs properly in local environment. But in Docker(of AWS EC2) isn't working.
When I docker logs my-spring-image
2021-11-09 11:10:49.793 ERROR 7 --- [ main] o.s.boot.SpringApplication : Application run failed
java.lang.NoClassDefFoundError: org/locationtech/jts/geom/Geometry
at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[na:na]
at java.base/java.lang.Class.privateGetPublicMethods(Class.java:3191) ~[na:na]
at java.base/java.lang.Class.getMethods(Class.java:1904) ~[na:na]
at org.springframework.data.repository.util.ReactiveWrappers.usesReactiveType(ReactiveWrappers.java:159) ~[spring-data-commons-2.5.5.jar!/:2.5.5]
at org.springframework.data.repository.core.support.AbstractRepositoryMetadata.isReactiveRepository(AbstractRepositoryMetadata.java:160) ~[spring-data-commons-2.5.5.jar!/:2.5.5]
at org.springframework.data.repository.config.RepositoryConfigurationExtensionSupport.useRepositoryConfiguration(RepositoryConfigurationExtensionSupport.java:366) ~[spring-data-commons-2.5.5.jar!/:2.5.5]
And this is my build.gradle
buildscript {
ext {
queryDslVersion = "4.4.0"
}
}
plugins {
id 'org.springframework.boot' version '2.5.5'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
// querydsl
id "com.ewerk.gradle.plugins.querydsl" version "1.0.10"
}
group = 'ssafy'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
// Web
implementation 'org.springframework.boot:spring-boot-starter-web'
// WebFlux
implementation 'org.springframework.boot:spring-boot-starter-webflux'
// MySQL Database
runtimeOnly 'mysql:mysql-connector-java'
//spatial query
compileOnly 'org.hibernate:hibernate-spatial'
// JPA Hibernate
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// Lombok
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
// Spring Security
implementation 'org.springframework.boot:spring-boot-starter-security'
// java-jwt : https://github.com/auth0/java-jwt
implementation 'com.auth0:java-jwt:3.18.2'
// OAuth
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// Validation
implementation 'org.springframework.boot:spring-boot-starter-validation'
//firebase
implementation 'com.google.firebase:firebase-admin:6.8.1'
// okhttp
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'
// swagger
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
implementation 'io.springfox:springfox-boot-starter:3.0.0'
// Dev Tools
developmentOnly 'org.springframework.boot:spring-boot-devtools'
// p6spy : https://github.com/gavlyukovskiy/spring-boot-data-source-decorator
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.7.1'
// Test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
// JsonObject 사용
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
//Tymeleaf
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'
// s3
implementation('org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE')
//javax
implementation("javax.annotation:javax.annotation-api:1.3.2")
annotationProcessor("javax.annotation:javax.annotation-api:1.3.2")
// querydsl
implementation 'com.querydsl:querydsl-jpa'
}
test {
useJUnitPlatform()
}
// querydsl
def querydslDir = "$buildDir/generated/querydsl"
querydsl {
jpa = true
querydslSourcesDir = querydslDir
}
sourceSets {
main.java.srcDir querydslDir
}
configurations {
querydsl.extendsFrom compileClasspath
}
compileQuerydsl {
options.annotationProcessorPath = configurations.querydsl
}
And this is application.yml
spring:
profiles:
include: API-KEY
## MYSQL 일 경우에
datasource:
url: jdbc:mysql://{ip-address}:3306/coffee_station?useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=UTF-8&serverTimezone=UTC
username: username
password: password
driver-class-name: com.mysql.cj.jdbc.Driver
jpa:
database: mysql
database-platform: org.hibernate.spatial.dialect.mysql.MySQL56InnoDBSpatialDialect
hibernate:
ddl-auto: update
properties:
hibernate:
format_sql: true
default_batch_fetch_size: 500
open-in-view: false
logging.level:
org.hibernate.SQL: debug
decorator:
datasource:
p6spy:
enable-logging: true
jwt:
secret: ---------secret key----------
cloud:
aws:
s3:
bucket: bucket-name
region:
static: ap-northeast-2
stack:
auto: false
And this is my dockerfile
FROM openjdk:11-jdk AS build
WORKDIR /app
COPY gradlew .
COPY gradle gradle
COPY build.gradle .
COPY settings.gradle .
COPY src src
COPY src/main/resources/application.yml src/main/resources/application.yml
COPY src/main/resources/application-API-KEY.properties src/main/resources/application-API-KEY.properties
RUN cat src/main/resources/application.yml
RUN cat src/main/resources/application-API-KEY.properties
RUN chmod +x gradlew
RUN rm -rf build/generated
RUN ["./gradlew", "clean", "build", "--stacktrace", "--exclude-task", "test"]
FROM openjdk:11-jdk
COPY --from=build /app/build/libs/runner-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT java -jar app.jar
and Jenkins always said "Build Success"
I checked application.yml and application-API-KEY.properties create successfully under {APP}/resources, too.
Please help me... :) Thank you
I found my error in build.gradle.
This problem was caused by 'compileOnly'
I changed my build.gradle.
compileOnly 'org.hibernate:hibernate-spatial'
-> implementation 'org.hibernate:hibernate-spatial'
Then it worked properly.

Conflict org.springframework.boot.test.context.SpringBootTest; and org.springframework.test.context.junit.jupiter.SpringExtension;

I'm developing a spring boot app.
In my build.gradle I have added the dependency:
compile group: 'org.springframework', name: 'spring-test', version: '3.1.1.RELEASE'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
to use MockMultipartFile in my service:
import org.springframework.mock.web.MockMultipartFile;
...
...
MultipartFile multipartFile = new MockMultipartFile("file",
file.getName(), "image/jpeg", IOUtils.toByteArray(input));
But now in the testing class I have this error:
This is my build.gradle:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compile 'org.hibernate:hibernate-core:5.2.11.Final'
compile 'org.hibernate:hibernate-entitymanager:5.2.11.Final'
compile 'mysql:mysql-connector-java'
compile 'org.apache.commons:commons-dbcp2:2.0.1'
compile 'javax.xml.bind:jaxb-api:2.3.1'
compile 'com.sun.xml.bind:jaxb-core:2.3.0'
compile 'com.sun.xml.bind:jaxb-impl:2.3.1'
compile 'javax.activation:activation:1.1.1'
compileOnly('org.projectlombok:lombok')
annotationProcessor 'org.projectlombok:lombok'
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
testCompile('org.mockito:mockito-junit-jupiter:2.23.0')
compile 'org.modelmapper:modelmapper:2.3.0'
compile 'com.google.firebase:firebase-admin:6.13.0'
compile group: 'org.springframework', name: 'spring-test', version: '3.1.1.RELEASE'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
}
You use a quite old version of Spring Test:
compile group: 'org.springframework', name: 'spring-test', version: '3.1.1.RELEASE'
I assume Spring Test 3.1.1 did not yet have the JUnit JUpiter SpringExtension. Either update spring-test to a more recent version or remove it from your build.gradle and let Spring Boot with the Spring Boot Starter Test manage the dependency version of spring-test.
So your updated dependencies section could look like the following:
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
// this is your testing swiss-army knife - take a look at its transitive dependency
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
compile 'org.hibernate:hibernate-core:5.2.11.Final'
compile 'org.hibernate:hibernate-entitymanager:5.2.11.Final'
compile 'mysql:mysql-connector-java'
compile 'org.apache.commons:commons-dbcp2:2.0.1'
compile 'javax.xml.bind:jaxb-api:2.3.1'
compile 'com.sun.xml.bind:jaxb-core:2.3.0'
compile 'com.sun.xml.bind:jaxb-impl:2.3.1'
compile 'javax.activation:activation:1.1.1'
compileOnly('org.projectlombok:lombok')
annotationProcessor 'org.projectlombok:lombok'
// REMOVE (managed by Spring Boot Starter Test) testCompile 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
// REMOVE (managed by Spring Boot Starter Test) testCompile('org.mockito:mockito-junit-jupiter:2.23.0')
compile 'org.modelmapper:modelmapper:2.3.0'
compile 'com.google.firebase:firebase-admin:6.13.0'
// REMOVE compile group: 'org.springframework', name: 'spring-test', version: '3.1.1.RELEASE'
implementation group: 'commons-io', name: 'commons-io', version: '2.6'

Could not find powermock-api-support-sources.jar during testCompileJava

While running tests in my project, I am getting the following error. We are unsure why the build is looking for source jar files.
04:15:21 > Task :clean UP-TO-DATE
04:15:28 > Task :compileJava FROM-CACHE
04:15:28 > Task :processResources
04:15:28 > Task :classes
04:15:31 > Task :bootWar
04:15:31 > Task :war SKIPPED
04:15:31 > Task :assemble
04:15:32 > Task :checkstyleMain FROM-CACHE
04:15:32 > Task :compileTestJava FAILED
04:15:32
04:15:32 FAILURE: Build failed with an exception.
04:15:32
04:15:32 * What went wrong:
04:15:32
Execution failed for task ':compileTestJava'.
04:15:32 > Could not resolve all files for configuration ':testCompileClasspath'.
04:15:32 > Could not find powermock-api-support-sources.jar (org.powermock:powermock-api-support:2.0.2).
04:15:32 Searched in the following locations:
04:15:32 file:/data/jenkins/.m2/repository/org/powermock/powermock-api-support/2.0.2/powermock-api-support-2.0.2-sources.jar
04:15:32 > Could not find powermock-core-sources.jar (org.powermock:powermock-core:2.0.2).
04:15:32 Searched in the following locations:
04:15:32 file:/data/jenkins/.m2/repository/org/powermock/powermock-core/2.0.2/powermock-core-2.0.2-sources.jar
04:15:32 > Could not find powermock-reflect-sources.jar (org.powermock:powermock-reflect:2.0.2).
04:15:32 Searched in the following locations:
04:15:32 file:/data/jenkins/.m2/repository/org/powermock/powermock-reflect/2.0.2/powermock-reflect-2.0.2-sources.jar
04:15:32
04:15:32 * Try:
04:15:32 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.
I am copying the dependencies.gradle snippet
compile 'org.apache.maven.plugins:maven-surefire-plugin:2.22.0'
testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.0"
testCompile 'org.junit.jupiter:junit-jupiter-params:5.2.0'
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.3.0"
testImplementation group: 'org.mockito', name: 'mockito-core', version: '2.23.4'
testImplementation 'org.mockito:mockito-junit-jupiter:2.23.4'
testCompile group: 'org.powermock', name: 'powermock-mockito-release-full', version: '1.6.4'
testCompile group: 'org.powermock', name: 'powermock-api-support', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-reflect', version: '2.0.0'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'
I am using java 11 ,springboot 2.0.5 and junit 5
After a lot of trial and error, we found that this is because one of the powermock libraries is still referring to junit 4, and it added some unwanted dependencies. So, we cleaned up the test dependencies, also avoided the libs that have PowerMockRunner. And that fixed the issue. Please find the latest dependencies.gradle snippet below,
testCompile(group: 'org.springframework.boot', name: 'spring-boot-test', version: springBootVersion) {
exclude (module: 'junit')
}
testCompile group: 'org.springframework', name: 'spring-test', version: springVersion
testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion) {
exclude(module: 'commons-logging')
}
compile 'org.apache.maven.plugins:maven-surefire-plugin:2.22.0'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.2'
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.3.2'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.3.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.23.4'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'

Liferay 7 Json WS External JAR

I have a osgi module (service-builder) to create a WS Json.
My Bnd.Bnd File is Like:
Bundle-Name: Dummy-service
Bundle-SymbolicName: Dummy.service
Bundle-Version: 1.0.0
Bundle-ClassPath:\
.,\
lib/joda-time.jar
-includeresource:\
lib/joda-time.jar=lib/joda-time-2.8.1.jar
Liferay-Require-SchemaVersion: 1.0.0
Liferay-Service: true
My build.gradle :
dependencies
{
compile group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "3.1.0"
compile group: "com.liferay", name: "com.liferay.osgi.util", version:
"3.0.0"
compile group: "com.liferay", name: "com.liferay.portal.spring.extender",
version: "2.0.0"
compile group: "com.liferay.portal", name: "com.liferay.portal.kernel",
version: "2.6.0"
compile group: "com.liferay", name: liferay.dynamic.data.mapping.api",
version: "3.5.4"
compile group: "com.liferay", name: "com.liferay.journal.api", version:
"2.6.1"
compile project(":modules: DummyApi: DummyApi-api")
compile group: 'joda-time', name: 'joda-time', version: '2.8.1'
}
buildService {
apiDir = "../Dummy-api/src/main/java"
}
group = "DummyEventApi"
When i generate de jar of the service and explode it, i have correctly the jar in the lib folder, but when i deploy the service i got the following error:
.service [515]_ Unresolved requirement: Import-Package: org.joda.convert_
I read (and based the code) in David article:
https://web.liferay.com/web/user.26526/blog/-/blogs/osgi-module-dependencies
I choosed the option 4, but when i deploy the service allways got the error, and if i remove the code from joda-time the service starts correctly.
Can somewone help ?
The answer is in this thread of liferay community:
https://web.liferay.com/community/forums/-/message_boards/message/89485697