Gradle: BuildListener#buildStarted(Gradle) has been deprecated - gradle

I have the following code in my build.gradle. It's just a library(submodule) that will become a gradle dependency after pass my CI.
ext.kotlin_version = '1.3.72'
buildscript { scriptHandler ->
apply from: 'common.gradle', to: scriptHandler
}
repositories {
jcenter()
google()
...
}
apply plugin: 'com.android.library' //THIS IS THE LINE 38 in my code
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'net.researchgate.release'
apply from: "ci_testing.gradle"
... more android gradle code
The common.gradle file
repositories {
...
}
dependencies {
...
}
After run the command ./gradlew assemble I have a successful execution and a warning pointing the line 38
$ ./gradlew assembleSmeRelease --warning-mode all
> Configure project :
BuildListener#buildStarted(Gradle) has been deprecated. This is scheduled to be removed in Gradle 7.0.
at build_8awlr5p8utk85ta3u2n2otdz2.run(/pathToMyLib/build.gradle:38)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)
I've found this solution (from year 2012) in https://discuss.gradle.org/t/usage-of-apply-from-in-buildscript-scope/1844/5

Related

How can I disable cache-redirector of `org.jetbrains.intellij` for some dependencies?

I want to introduce com.alibaba:fastjson:1.2.58 in my plugin project, but when gradle resolve dependencies, the org.jetbrains.intellij plugin redirect the download request to https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom, which is not exists.
How can I force gradle download this dependency from mavenCentral ?
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url 'https://dl.bintray.com/jetbrains/intellij-plugin-service'
}
}
}
plugins {
id "org.jetbrains.intellij" version "0.4.4"
}
dependencies {
implementation 'com.alibaba:fastjson:1.2.58'
}
apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
apply plugin: 'java'
sourceCompatibility = 1.8
targetCompatibility = 1.8
intellij {
version ideaVersion
updateSinceUntilBuild false
plugins = [
"com.jetbrains.php:${phpPluginVersion}",
"com.jetbrains.php.blade:${bladePluginVersion}",
'CSS',
'java-i18n',
'properties',
'git4idea'
]
pluginName 'tw tools'
}
patchPluginXml {
sinceBuild '173'
}
group 'com.baiguiren'
version '1.2'
wrapper {
gradleVersion '5.4.1'
}
Output of ./gradlew clean && ./gradlew build:
BUILD SUCCESSFUL in 0s
1 actionable task: 1 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':prepareSandbox'.
> Could not resolve all files for configuration ':runtimeClasspath'.
> Could not find com.alibaba:fastjson:1.2.58.
Searched in the following locations:
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom
https://cache-redirector.jetbrains.com/www.jetbrains.com/intellij-repository/releases/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/com.alibaba/fastjson/1.2.58/ivy-1.2.58.xml
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/fastjson-1.2.58-withKotlin-withSources.xml
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/com.alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/fastjson.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2018.3.5/78cbcd517ec112fbb0c7b45b00b464c1aa6371f3/fastjson-1.2.58-[classifier].jar
https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.pom
https://cache-redirector.jetbrains.com/plugins.jetbrains.com/maven/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/com.alibaba/fastjson-1.2.58.xml
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/2018.3.5/3abea719ce307bc4f573cba4e3d86f4e35cab07/ideaIU-2018.3.5/plugins/fastjson/fastjson.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/fastjson-1.2.58/fastjson.jar
file:/Users/ruby/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2018.3.5/78cbcd517ec112fbb0c7b45b00b464c1aa6371f3/fastjson-2018.3.5.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
I have tried to Invalid caches and restart, but not work.
I even tried to remove org.jetbrains.intellij plugin, but it's required by the project.
There is nothing wrong with cache-redirector, it's just one of the repositories registered in the project, Gradle checks them all.
Try to add the mavenCentral repo to your build.gradle (at the moment it's defined for buildscript only):
repositories {
mavenCentral()
}

Could not find method compile() for a multi module project

dependencies {
compile project('client')
compile project('-cache
')
Now when I comment out compile project('product-cache-client') it moves to the next one and compains about that.
I tried to add it to gradle.settings in that module like so:
include('client')
include('cache')
But I still get the same error. I even tried adding this to the gradle.settings
project('lib/cache').projectDir = "$rootDir/lib/cache" as File
And still get the same result.
Gradle 4.4
main gradle.build file:
subprojects {
dependencies {
compile project('client')
compile project('cache')
}
repositories{
jcenter()
mavenCentral()
}
}
configure(subprojects){
apply plugin: 'maven'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
}
repositories {
}
buildscript {
ext {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
jcenter()
mavenCentral()
}
Add the java plugin on top of your parent build, for me this works:
apply plugin:'java'
It is recommended here - the second answer Could not find method compile() for arguments Gradle
And also switch the 'dependencies' with 'repositories' - at least in the sample of build.gradle you wrote here they are switched.
when you define dependency as compile then it can not be accessible at the runtime. If you run the project through IDE then it works but when you run with gradle bootRun or mvn spring-boot:run command then above error will throw. So have to just replace compile with implementation.
dependencies {
implementation project('client')
implementation project('cache')
}

SonarQube - java/groovy multimodule project scan

I have:
SonarQube v5.6 + Groovy plugin
gradle 3.5
org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.5
Configuration:
def sourceProjects = allprojects.findAll { it.file('src/main').exists() }
configure(sourceProjects) {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: "org.sonarqube"
sourceSets.main.java.srcDirs = []
sourceSets.main.groovy.srcDirs = ['src/main/java', 'src/main/groovy']
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
}
dependencies {
compile lib.groovy_core
}
}
Project structure:
rootDir
apps
app-backend
app-ui
modules
module 1
module 2
module 3
Whenever I run: $ ./gradlew sonarqube what happens is when it goes through different modules, it does not aggregate sonar reports. It throws in last module scan and overwrites anything that was already stored. So after running this, I just get the results for last modules that gradle executor processed. Can something be done about that?
For what its worth I solved this issue by applying sonar cube to the root project only:
project(':') {
apply plugin: 'org.sonarqube'
}

Could not find method cargo() for arguments

I am trying to deploy war to tomcat with gradle cargo,i am getting error could not found method cargo()
C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle>gradle build
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\naresh.vatsal\workspace_spring_jan14\SpringMvcUsingGradle\build.gradle' line: 45
What went wrong:
A problem occurred evaluating root project 'SpringMvcUsingGradle'.
Could not find method cargo() for arguments [build_3gitu3al50b7kv8zi1ebj3qsr$runclosure3#302aa00f] on root project 'SpringMvcUsingGradle'.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'war'
apply plugin: 'com.bmuschko.tomcat-base'
apply plugin: 'com.bmuschko.cargo-base'
ext.tomcatVersion = '7.0.67'
sourceCompatibility = 1.7
buildscript {
repositories {
maven {
url "https://plugins.grdev.net/m2/"
}
}
dependencies {
classpath "com.bmuschko:gradle-tomcat-plugin:2.2.4"
classpath 'com.bmuschko:gradle-cargo-plugin:2.2'
}
}
repositories {
mavenCentral()
}
dependencies {
def cargoVersion = '1.4.5'
cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
"org.codehaus.cargo:cargo-ant:$cargoVersion"
compile 'org.springframework:spring-context:4.0.0.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.0.RELEASE'
compile 'org.aspectj:aspectjrt:1.7.4'
compile 'javax.inject:javax.inject:1'
compile 'javax.servlet:jstl:1.2'
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:jcl-over-slf4j:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.5'
compile 'log4j:log4j:1.2.15'
testCompile 'junit:junit:4.7'
}
cargo {
containerId = 'tomcat7x'
port = 8080
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
output = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}
}
war {
version = ''
}
It seems, that you've applied the wrong plugin at the moment. Just change:
apply plugin: 'com.bmuschko.cargo-base'
to
apply plugin: 'com.bmuschko.cargo'
Because, when you apply the com.bmuschko.cargo-base plugin, you have to configure each task individually, according to the plugin description.
And one more, there is no property output, which could be defined within the local closure, but there is an outputFile property, so, your local closure should look like:
local {
homeDir = file('C:/mdi/soft/apache-tomcat-7.0.67')
outputFile = file('C:/mdi/soft/apache-tomcat-7.0.67/output.log')
}

running gradle jettyRun error

I am trying to run my spring Boot Application using gradle jettyRun but when gradle is compilingJava these errors appear:
alberto#alberto-desktop:~/Credito/PalmasServer$ gradle jettyRun
:compileJava
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all dependencies for configuration ':compile'.
Could not find org.springframework.data:spring-data-rest-webmvc:.
Required by:
:PalmasServer:unspecified
Could not find org.hsqldb:hsqldb:.
Required by:
:PalmasServer:unspecified
Could not find com.h2database:h2:.
Required by:
:PalmasServer:unspecified
Could not find nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:.
Required by:
:PalmasServer:unspecified
Could not find org.thymeleaf.extras:thymeleaf-extras-springsecurity3:.
Required by:
:PalmasServer:unspecified
Could not find org.thymeleaf:thymeleaf-spring4:.
Required by:
:PalmasServer:unspecified
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 35.664 secs
And this is my build.gradle File:
buildscript {
ext {
springBootVersion = '1.1.9.RELEASE'
}
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.1.9.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'application'
sourceCompatibility = 1.7
targetCompatibility = 1.7
war {
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://maven.springframework.org/milestone" }
flatDir {
dirs 'lib'
}
}
dependencies {
compile "xerces:xercesImpl:2.9.0"
compile "net.sourceforge.nekohtml:nekohtml:1.9.12"
compile "nekohtml:nekodtd:0.1.11"
compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
compile("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}")
compile("org.springframework.data:spring-data-rest-webmvc")
compile("org.springframework.boot:spring-boot-starter-security:1.0.2.RELEASE")
compile("org.springframework.security.oauth:spring-security-oauth2:2.0.0.RC2")
compile("org.springframework.security.oauth:spring-security-oauth2-javaconfig:1.0.0.M1")
compile("org.hsqldb:hsqldb")
compile("com.h2database:h2")
compile("com.google.guava:guava:17.0")
compile("org.apache.commons:commons-lang3:3.3.2")
compile("org.apache.httpcomponents:httpclient:4.3.4")
compile("com.squareup.retrofit:retrofit:1.6.0")
compile("commons-io:commons-io:2.4")
compile("com.github.davidmarquis:fluent-interface-proxy:1.3.0")
compile ("org.springframework.boot:spring-boot-starter-security:1.0.2.RELEASE")
compile ("javax.servlet:jstl:1.2")
compile ("commons-fileupload:commons-fileupload:1.3.1")
testCompile("junit:junit")
compile("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect")
compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity3")
compile("org.thymeleaf:thymeleaf-spring4")
def poiVersion = "3.10.1"
compile "org.apache.poi:poi:${poiVersion}"
compile "org.apache.poi:poi-ooxml:${poiVersion}"
compile "org.apache.poi:ooxml-schemas:1.1"
}
jar {
baseName = 'gs-uploading-files'
version = '0.1.0'
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
Why when i am running in Eclipse all is OK????
Any other idea?
Try adding the following piece of code:
compile fileTree(dir: 'lib', include: ['*.jar'])
to dependencies block.

Resources