quarkus gradle test not executed - gradle

I'am trying the quarkus getting-started project. With maven the contained unittest is executed. Then I tried the proposed gradle build file, because we use gradle instead of maven. When I run gradle test, the unittest is definitivly not executed (I know, because I modified it to fail).
apply plugin: 'java'
apply plugin: 'io.quarkus.gradle.plugin'
buildscript {
repositories {
mavenCentral()
maven {
//this is temporary, all dependencies should be in central soon
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
classpath 'io.quarkus:quarkus-gradle-plugin:0.11.0'
}
}
repositories {
mavenCentral()
maven {
url 'http://repository.jboss.org/nexus/content/groups/public'
}
}
dependencies {
compileOnly group: 'io.quarkus', name: 'quarkus-resteasy', version:'0.11.0'
testCompile group: 'io.quarkus', name: 'quarkus-junit5', version:'0.11.0'
testCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.3.0'
}
Is this a bug or do I anything wrong?

OK, I found the problem. Gradle does not use JUnit5 out of the box. You have to add the following to the build.gradle to get gradle starting the tests:
test {
useJUnitPlatform()
}

Related

Getting 401 Unauthorized during Gradle build for Atlassian Renderer library

I think by Gradle build problem is related to this Spring article about Spring Artifactory instance repo.spring.io permissions. Pls help me correct my build.gradle which has started failing recently after upgrading to Gradle 5.0.
Snippet from build.gradle
buildscript {
ext {
springBootVersion = SPRING_BOOT_VERSION
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath('se.transmode.gradle:gradle-docker:1.2')
}
}
apply plugin: 'java'
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-milestone'
}
maven { url "https://packages.atlassian.com/maven/repository/public" }
}
dependencies {
compile (group: 'com.atlassian.renderer', name: 'atlassian-renderer', version:'8.0.5') {
exclude(module: 'servlet-api')
exclude(module: 'radeox')
// https://mvnrepository.com/artifact/javax.activation/activation
compile group: 'javax.activation', name: 'activation', version: '1.1.1'
}
}
The error i get is
> Could not resolve com.atlassian.renderer:atlassian-renderer:8.0.5.
> Could not get resource 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'.
> Could not HEAD 'https://repo.spring.io/libs-milestone/com/atlassian/renderer/atlassian-renderer/8.0.5/atlassian-renderer-8.0.5.pom'. Received status code 401 from server: Unauthorized
Please help.
I added jCenter in the repositories in build.gradle and it worked for me.
jcenter()
I think the atlassian-renderer is no longer available with maven repo.

Jackson Databind Issue - Gradle

I tried to deploy strom Topology written with 2.2.0 at local with below command:
./storm local ./sample.jar com.sample.processor.storm.Main config.yml
But unfortunately, I got this issue:
java.lang.NoClassDefFoundError:
Could not initialize class
com.fasterxml.jackson.databind.deser.std.JdkDeserializers
I had included this at gradle file , provided below the gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1"
}
}
repositories {
maven { url "http://clojars.org/repo"}
maven { url "https://repository.cloudera.com/artifactory/cloudera-repos/" }
jcenter { url "http://jcenter.bintray.com/" }
}
configurations {
includeInJar
}
dependencies {
includeInJar 'org.codehaus.jackson:jackson-core-asl:1.9.13'
includeInJar 'org.codehaus.jackson:jackson-mapper-asl:1.9.12'
includeInJar 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
compile ('org.apache.storm:storm-core:2.2.0') {
exclude group: 'org.slf4j'
exclude group: 'com.fasterxml.jackson.core'
}
compile 'org.codehaus.jackson:jackson-core-asl:1.9.13'
compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.12'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.8'
}
Compilation is successful, I was able to test at IDE at runtime, but only during local deployment, above error occurs
Any help appreciated. Thanks in Advance!
Same gradle-file worked with storm 0.10.0 but not working at 2.2.0
I removed fasterxml dependencies from gradle build as this conflicts with jackson library and it builds JAR executable fine.

How to start up this project using the gradle command line?

I am following the instruction here https://ktor.io/quickstart/quickstart/gradle.html#intellij-start-a-project to build a simple web server with Netty in Kotlin.
Here is my build.gradle
group 'Example'
buildscript {
ext.kotlin_version = '1.3.61'
ext.ktor_version = '1.3.0'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
mainClassName = 'MainKt'
sourceCompatibility = 1.8
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
experimental {
coroutines "enable"
}
}
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "io.ktor:ktor-server-netty:$ktor_version"
compile "ch.qos.logback:logback-classic:1.2.3"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
I want to be able to start the server up without using IntelliJ.
I have tried
gradle tasks --all
but I cannot find any task that can let me to start up the netty-powered server.
I tried startScripts but it complaints about Deprecated Gradle features
What is the command line to start up the sever? Or do I need to make further changes to the gradle file?
You applied and configured the application plugin therefore the run task is what you're looking for. So:
./gradlew run
should launch your application.

Configuration for Gradle 4.7 to generate the HTML report for JUnit 5 tests

I have an app based as follows:
Spring Framework 5.0.4.RELEASE
Gradle 4.7 - multimodule project configured through
JUnit 5.1.1
The configuration about Gradle with JUnit is in the build.gradle file located in the root module:
...
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.junit.platform.gradle.plugin'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
repositories {
jcenter()
}
ext {
...
junitVersion = '5.1.1'
...
}
dependencies {
...
//Testing
...
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testCompile "org.junit.jupiter:junit-jupiter-params:$junitVersion";
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
....
}
test {
useJUnitPlatform()
}
}
//This location is mandatory
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.junit.platform:junit-platform-gradle-plugin:1.1.0"
}
}
Through Jenkins I execute:
gradle :thymeleaf-02-infrastructure:test --parallel
and with Publish JUnit test result report is configured to thymeleaf-02-infrastructure/build/test-results/junit-platform/*.xml
From above all work fine, I can see in Jenkins the #Test passed but Gradle does not generate the report directory with the expected html file.
Even if directly the gradle :thymeleaf-02-infrastructure:test --parallel command is executed in the terminal, all work (tests passe), but Gradle does not generate the report directory with the expected html file.
I already have read these links:
How to use JUnit 5 with Gradle?
How to create an HTML report for JUnit 5 tests?
And well I am using
test {
useJUnitPlatform()
}
and Gradle is >4.6, 4.7, so what is missing?
You need to remove the org.junit.platform.gradle.plugin because it disables the standard test task by default.

Standalone Kotlin Gradle plugin not found when trying to apply to other project

I'm trying to make a custom standalone Kotlin plugin for Gradle and am trying to apply that to another project, but am getting a Plugin with id 'my.id.license-tools' not found error when trying to apply it to another project.
This is the structure of the plugin's project:
license-tools
+--src
+--main
| +--java
| |
| +--kotlin
| | +--my.id
| | +--LicenseTools.kt
| |
| +--resources
| +--META-INF.gradle-plugins
| +--my.id.license-tools.properties
+--test
+--build.gradle
This is my build.gradle file:
buildscript {
ext.kotlin_version = '1.2.21'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
group 'my.id'
version '0.1'
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'idea'
apply plugin: 'maven'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile gradleApi()
testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Then we have the Plugin class LicenseTools.kt, which I've held very simple to make sure the error didn't come from there:
package my.id
import org.gradle.api.Plugin
import org.gradle.api.Project
open class LicenseTools: Plugin<Project> {
override fun apply(project: Project?) {
println("License-Tools plugin has been applied")
}
}
And lastly my.id.license-tools.properties:
implementation-class=my.id.LicenseToolsKt
I've also tried
implementation-class=my.id.LicenseTools
After building everything with ./gradlew clean build I've run ./gradlew install to install the whole thing to the local Maven repository, which it did successfully.
Then I went ahead and added the following to my other project's buildscript block:
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "my.id:license-tools:0.1"
}
And after that added
apply plugin: 'my.id.license-tools'
After trying out many different things, like changing to the new plugins block or making sure the artifacts get correctly installed to the local maven repository I can't find the root of the problem, since according to the many guides I've read through, this should be the correct way to go about making a standalone plugin.
you probably figured by now, but your my.id.license-tools.properties should be named my.id.properties
the content should then be implementation-class=my.id.LicenseTools
then the classpath should be named
classpath "my.id:license-tools:0.1" -> classpath "my.id:LicenseTools:0.1"
and
apply plugin: 'my.id.license-tools' -> apply plugin: 'my.id.LicenseTools'
so that it always is:
package: my.id
name: LicenseTools
I haven't actually tested all of that, though.

Resources