The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin in instead - maven

I´m trying to run a project using gradle but I´m getting the following error.
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\ISEP\ODSOFT\Projects\odsoft-21-22-nmb-g311\odsoft-21-22-nmb-g311\project\build.gradle' line: 4
* What went wrong:
An exception occurred applying plugin request [id: 'fr.putnami.gwt', version: '0.4.0']
> Failed to apply plugin class 'org.gradle.api.plugins.MavenPlugin'.
> The legacy `maven` plugin was removed in Gradle 7. Please use the `maven-publish` plugin instead. See https://docs.gradle.org/7.2/userguide/publishing_maven.html#publishing_maven for details
* 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.
The command I´m using to run project is gradle gwtRun.
I leave below my gradle bulid file
plugins {
id "fr.putnami.gwt" version "0.4.0"
id "maven-publish"
}
apply plugin: 'war'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
//Java version compatibility to use when compiling Java source.
sourceCompatibility = 1.8
//Java version to generate classes for.
targetCompatibility = 1.8
//Script Version
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
//testCompile 'junit:junit:4.12'
//testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation 'org.easymock:easymock:2.5.2'
testImplementation 'com.google.gwt:gwt-dev:2.8.1'
implementation 'net.sourceforge.plantuml:plantuml:8001'
//compile 'net.sourceforge.plantuml:plantuml:8001'
}
javadoc {
options.addStringOption("sourcepath", "")
}
// If we woant to use the default ant build inside gradle
// ant.importBuild "build.xml"
putnami{
module 'pt.isep.cms.Showcase'
//module 'com.google.gwt.sample.contacts.Contacts'
/** add gwt nature on eclipse project. require apply plugin: 'eclipse' to work. default : false*/
googlePluginEclipse = true
gwtVersion='2.8.1'
compile {
sourceLevel = '1.8'
}
jetty {
/** enable debugging. */
debugJava = true
/** debug port to listen. */
debugPort = 8000
/** wait for debugger attachment. */
debugSuspend = false
}
}
// Jacoco
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
}
}
// This task generates the coverage report for the integration tests.
// Notice that it only includes data about the server code sice Jaccoco is not able to get data about cliente code that is transpiled to javascript
task jacocoIntegrationReport(type: org.gradle.testing.jacoco.tasks.JacocoReport) {
sourceSets sourceSets.main
executionData = files("${buildDir}/jacoco/integrationTest.exec")
reports {
html.enabled = true
xml.enabled = false
csv.enabled = false
}
}
// Integration Tests
task integrationTest(type: Test) {
filter {
//all GWT unit tests, by naming convention
includeTestsMatching "*GWTTest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
excludes = ["com/steadystate/**"]
}
// These Properties are required to run gwt integration tests
systemProperties['gwt.args'] = "-devMode -logLevel WARN -war www-test"
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
// Unit Tests
test {
filter {
//all JRE unit tests, by naming convention
includeTestsMatching "*JRETest*"
}
jacoco {
append = true
enabled = true
//classDumpFile = file("${buildDir}/jacoco/classpathdumps")
}
}
From what I understood the plugin maven was removed in the version 7 of gradle. Is this sentence correct? Or is the putnami plugin that was removed?
What should I do to make it to work?

The plugin fr.putnami.gwt applies the maven plugin internally:
https://github.com/Putnami/putnami-gradle-plugin/blob/master/src/main/java/fr/putnami/gwt/gradle/PwtLibPlugin.java#L47
Therefore, fr.putnami.gwt is not compatible with Gradle 7.
As stated in the README in the repo:
A fork of it that is still supported and has a newer release is available at https://github.com/esoco/gwt-gradle-plugin. Please use the new version if you need GWT support for Gradle.
So, then the following should work:
plugins {
id "de.esoco.gwt" version "1.1.1"
}

Related

No value has been specified for property 'mainClassName' in shadowJar

I am compile flink using gradle(v6.0.1) build tool like this, but show this error:
~ ⌚ 13:53:42
$ bash -c "$(curl https://flink.apache.org/q/gradle-quickstart.sh)" -- 1.10.0 2.11
~/quickstart ⌚ 14:08:22
$ ./gradlew clean shadowJar
> Task :shadowJar FAILED
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':shadowJar' (type 'ShadowJar').
> No value has been specified for property 'mainClassName'.
* 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.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
4 actionable tasks: 4 executed
this this my gradle build.gradle:
buildscript {
repositories {
jcenter() // this applies only to the Gradle 'Shadow' plugin
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
}
}
plugins {
id 'java'
id 'application'
// shadow plugin to produce fat JARs
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
apply plugin: 'application'
// artifact properties
group = 'org.myorg.quickstart'
version = '0.1-SNAPSHOT'
mainClassName = 'org.myorg.quickstart.StreamingJob'
description = """Flink Quickstart Job"""
ext {
javaVersion = '1.8'
flinkVersion = '1.10.0'
scalaBinaryVersion = '2.11'
slf4jVersion = '1.7.7'
log4jVersion = '1.2.17'
}
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]
// declare where to find the dependencies of your project
repositories {
mavenCentral()
}
// NOTE: We cannot use "compileOnly" or "shadow" configurations since then we could not run code
// in the IDE or with "gradle run". We also cannot exclude transitive dependencies from the
// shadowJar yet (see https://github.com/johnrengelman/shadow/issues/159).
// -> Explicitly define the // libraries we want to be included in the "flinkShadowJar" configuration!
configurations {
flinkShadowJar // dependencies which go into the shadowJar
// always exclude these (also from transitive dependencies) since they are provided by Flink
flinkShadowJar.exclude group: 'org.apache.flink', module: 'force-shading'
flinkShadowJar.exclude group: 'com.google.code.findbugs', module: 'jsr305'
flinkShadowJar.exclude group: 'org.slf4j'
flinkShadowJar.exclude group: 'log4j'
}
// declare the dependencies for your production and test code
dependencies {
// --------------------------------------------------------------
// Compile-time dependencies that should NOT be part of the
// shadow jar and are provided in the lib folder of Flink
// --------------------------------------------------------------
compile "org.apache.flink:flink-java:${flinkVersion}"
compile "org.apache.flink:flink-streaming-java_${scalaBinaryVersion}:${flinkVersion}"
// --------------------------------------------------------------
// Dependencies that should be part of the shadow jar, e.g.
// connectors. These must be in the flinkShadowJar configuration!
// --------------------------------------------------------------
//flinkShadowJar "org.apache.flink:flink-connector-kafka-0.11_${scalaBinaryVersion}:${flinkVersion}"
compile "log4j:log4j:${log4jVersion}"
compile "org.slf4j:slf4j-log4j12:${slf4jVersion}"
// Add test dependencies here.
// testCompile "junit:junit:4.12"
}
// make compileOnly dependencies available for tests:
sourceSets {
main.compileClasspath += configurations.flinkShadowJar
main.runtimeClasspath += configurations.flinkShadowJar
test.compileClasspath += configurations.flinkShadowJar
test.runtimeClasspath += configurations.flinkShadowJar
javadoc.classpath += configurations.flinkShadowJar
}
run.classpath = sourceSets.main.runtimeClasspath
jar {
manifest {
attributes 'Built-By': System.getProperty('user.name'),
'Build-Jdk': System.getProperty('java.version')
}
}
shadowJar {
configurations = [project.configurations.flinkShadowJar]
}
I am read the some answer to tell that the script do dot have mainClassName,but my config contains the mainClassName config,what should I do to fix this error? I am using macOS catalina.
downgrade the gradle to 4.0.1,it works.this is the gradle-wrapper.properties config:
#Mon Jan 06 13:52:34 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
this is the build command:
~/quickstart ⌚ 14:48:25
$ ./gradlew clean shadowJar
Downloading https://services.gradle.org/distributions/gradle-4.0.1-all.zip
........10%.........20%........30%.........40%........50%.........60%.........70%........80%.........90%........100%
Starting a Gradle Daemon (subsequent builds will be faster)
BUILD SUCCESSFUL in 1m 46s
4 actionable tasks: 4 executed
maybe help you.

gradle jacoco plugin not generate exec files

I've done gradle migration from gradle 3.5 to gradle 4.6. After migration exec files have stopped generated. '/build' folder doesn't contain 'jacoco' folder.
If I run gradle command with -- debug it writes in log :
[org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter]
Skipping task ':common:jacocoTestReport' as task onlyIf is false.
Here is part of gradle script:
subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
...
jacocoTestReport {
reports {
xml.enabled true
csv.enabled false
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ['**/dto/**', '**/endpoint/**','**/enpoints/**', '**/spring/**',
'**/servlet/**','**/handler/**', '**/jpa/**', '**/filter/**', '**/events/**', '**/dao/**',
'**/exception/**', '**/http/**', '**/jdbc/**', '**/bigquery/**', '**/enums/**',
'**/repository/**', '**/combination/**', '**/datastore/**', '**/cassandra/**',
'**/google/**', '**/exceptions/**', '**/logging/**', '**/JavaGeneratedContext.java', '**/Q*.java'])
})
}
}
test {
enabled = !skipTests
allJvmArgs = [
'-Dfile.encoding=utf-8'
]
useJUnit {
excludeCategories 'com.severn.common.test.IntegrationTest'
}
/*jacoco {
enabled = true
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
}*/
finalizedBy jacocoTestReport
}
...
}
Make sure:
1) Your debug info is enabled during compile in your top level Gradle file (allprojects { ... } ). See here for more info: Jacoco Unit and Integration Tests coverage - individual and overall
tasks.withType(Compile) {
options.debug = true
options.compilerArgs = ["-g"]
}
2) Try removing the whole Jacoco configuration from the test task (make sure you place the .exec file if generated in the default location where jacocoTestReport task expects it). Make sure test task is running (and not getting excluded somehow). For testing purpose (to narrow down this .exec not getting created issue), you can force jacocoTestReport task to dependOn test task.
tasks.withType(Test) {enabled = true}
3) See latest Gradle 4.6 bundle (tar/zip) for Jacoco examples for a Java single/multi level project to get hint.
PS: Default JaCoCo version upgraded to 0.8.0 See if forcing this version within jacoco block helps.
https://docs.gradle.org/4.6/release-notes.html
The JaCoCo plugin has been upgraded to use JaCoCo version 0.8.0 by default.

jUnit 5 HTML Report using Gradle 4.6 [duplicate]

This question already has an answer here:
Configuration for Gradle 4.7 to generate the HTML report for JUnit 5 tests
(1 answer)
Closed 4 years ago.
I am trying to generate HTML report of JUnit 5 test case.
Here is my Gradle.build file
buildscript {
ext {
springBootVersion = '2.0.0.M3'
}
repositories {
maven { url 'https://zz-artifactory.zzzz.com/artifactory/maven' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.2.0-M1'
classpath "io.spring.gradle:dependency-management-plugin:1.0.0.RC1"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: "io.spring.dependency-management"
apply from: "CodeCoverage.gradle"
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.2')
compile('org.mybatis.spring.boot:mybatis-spring-boot:1.3.2')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter-test:1.3.2')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-aop')
compile("org.junit.jupiter:junit-jupiter-api:5.2.0-M1")
compile('org.junit.jupiter:junit-jupiter-migrationsupport:5.0.2')
compile("org.junit.jupiter:junit-jupiter-engine:5.2.0-M1")
compile("junit:junit:4.12")
compile("org.junit.vintage:junit-vintage-engine:5.2.0-M1")
compile(group: 'org.junit.platform', name: 'junit-platform-launcher', version: '1.2.0-M1')
compile(group: 'org.junit.platform', name: 'junit-platform-runner', version: '1.2.0-M1')
testCompile('com.h2database:h2:1.4.196')
testCompile('org.mockito:mockito-all:2.0.2-beta')
testCompile('org.mockito:mockito-core:2.8.9')
}
test {
useJUnitPlatform()
}
junitPlatform {
// platformVersion '1.2.0-M1'
filters {
engines {
// include 'junit-jupiter', 'junit-vintage'
// exclude 'custom-engine'
}
tags {
include 'Smoke'
//exclude 'slow'
}
}
}
subprojects {
apply plugin: 'java'
test {
reports.html.enabled = false
}
}
task testReport(type: TestReport) {
destinationDir = file("$buildDir/reports123/allTests")
// Include the results from the `test` task in all subprojects
reportOn subprojects*.test
}
I have used testReport as per
Gradle docs Links
When i run the Gradle task, It runs all the test case, generate XML reprts, but doesnot generate HTML report
In the build log, i see
:testReport NO-SOURCE
any suggestion why it says NO-SOURCE ??
Thanks
You are doing one thing too many. You should either use 'org.junit.platform.gradle.plugin' or test { useJUnitPlatform } but not both.
The standard gradle (html) test reporting will only work with the latter.

Allure generates empty reports page on local machine

As the title says I cannot force Allure 2 to generate reports for me on local machine.
I've tried a lot of things from Google but nothing helped. I use Kotlin+Selenide+TestNG to write tests, if it helps somehow :)
I'm a little bit confused with Allure because it has version for testNG and version for Gradle - which one should be used? Both?
Here's my build.gradle file:
group 'RegisteredUserFlow'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = "1.1.2-2"
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "ru.d10xa:gradle-allure-plugin:0.5.5"
}
}
apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'ru.d10xa.allure'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
allure {
aspectjweaver = true
testNG = true
}
repositories {
jcenter()
}
configurations {
agent
}
dependencies {
agent "org.aspectj:aspectjweaver:1.8.10"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2"
testCompile "com.codeborne:selenide:4.4.3"
testCompile "org.testng:testng:6.10"
testCompile "io.qameta.allure:allure-testng:2.0-BETA6"
testCompile "io.github.bonigarcia:webdrivermanager:1.6.2"
}
test.doFirst {
jvmArgs "-javaagent:${configurations.agent.singleFile}"
}
test {
useTestNG(){
suites 'src/test/kotlin/testng.xml'
}
systemProperty 'allure.results.directory', 'build/allure-results'
systemProperty 'allure.link.issue.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
systemProperty 'allure.link.tms.pattern', 'https://github.com/allure-framework/allure-docs/issues/{}'
}
tasks.withType(Test)*.finalizedBy allureReport
Commands I used were: allure serve build/allure-results and gradlew clean test allureReport
Also, do I need Java plugin?
Appreciate any help!
Thanks!
P.S. Here's the error I get in console after gradlew clean test allureReport command:
Execution failed for task ':allureReport'.
> Could not resolve all dependencies for configuration ':allureReport'.
> Could not resolve org.slf4j:slf4j-api:1.7.12.
Required by:
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > org.slf4j:slf4j-simple:1.7.12
project : > ru.yandex.qatools.allure:allure-bundle:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-data:1.4.24.RC3 > ru.yandex.qatools.allure:allure-report-plugin-api:1.4.24.RC3 > ru.yandex.qatools.allure:allure-model:1.4.24.RC3
The problem is that ru.d10xa:gradle-allure-plugin:0.5.5 is not support Allure 2. We are working on brand new Allure Gradle plugin that available here https://github.com/allure-framework/allure-gradle
At the moment you can use allure-commandline to generate the report at local machine and Allure Jenkins/Teamcity plugin to generate the report on CI.
Update
New Allure Gradle plugin that supports Allure 2 is available now. See the docs https://docs.qameta.io/allure/2.0/#_gradle_3 for more details.

Gradle build for Java project is failing

Below build.gradle file for java project is failing
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
testCompile "log4j:log4j:1.2.9"
testCompile 'org.testng:testng:6.8'
}
test {
// enable TestNG support
task testNGTests(type: Test) {
useTestNG() {
suites 'src/test/resources/testng.xml'
useDefaultListeners = true
}
}
}
Error:
Couldnot find property 'projectDir' on org.gradle.api.tasks.testing.testng.TestNGOptions_Decorated#1595f1bb.
Then I tried in using setting.gradle file with below code:
rootProject.name = 'AutoTest_Gradle'
project(':AutoTest_Gradle').projectDir = 'C:/workspace/AutoTest_Gradle'
Here AutoTest_Gradle is the project name.Then it is failed with below error:
Where:
Settings file 'C:\workspace\AutoTest_Gradle\settings.gradle
What went wrong:`enter code here
A problem occurred evaluating settings 'AutoTest_Gradle'.
Project with path ':AutoTest_Gradle' could not be found.
Can anyone help on this?

Resources