Gradle 5: Failed to apply plugin [id 'aspectj'] - spring

I am trying to run a build.gradle file that looks like this and which returns an error on line apply plugin: 'aspectj'
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/release" }
maven { url "http://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-milestone" }
maven { url "https://maven.eveoh.nl/content/repositories/releases" }
}
dependencies {
classpath "nl.eveoh:gradle-aspectj:2.0"
}
}
apply plugin: 'aspectj'
jar {
manifest {
attributes(
"Created-By": "Iuliana Cosmina",
"Specification-Title": "Pro Spring 5",
"Main-Class": "com.apress.prospring5.ch5.AspectJDemo",
"Class-Path": configurations.compile.collect { it.getName() }.join(' ')
)
}
}
The error message is as follows:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/me/Spring/pro-spring-5-master/chapter05/aspectj-aspects/build.gradle' line: 17
* What went wrong:
A problem occurred evaluating project ':chapter05:aspectj-aspects'.
> Failed to apply plugin [id 'aspectj']
> Could not find method deleteAllActions() for arguments [] on task ':chapter05:aspectj-aspects:compileJava' of type org.gradle.api.tasks.compile.JavaCompile.
What am I doing wrong here?

AspectJ is not compatible with Gradle 5.0 - see issues #7861 and #8063.
The most easy might be to replace the plugin; eg. with io.freefair.aspectj.post-compile-weaving, because aspectj.gradle had been last updated 2 years ago (it seems abandoned).

I have fixed the issue and published a new version to jcenter. Find it here: https://bintray.com/zebalu/releases/gradle-aspectj
currently you need this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'io.github.zebalu:gradle-aspectj:2.3.3'
}
}
apply plugin: 'gradle-aspectj'
// rest of your code

Related

Why can't Gradle resolve org.connectbot.jbcrypt:jbcrypt:1.0.0 from the Maven Central Repository?

I'm using Gradle 6.9 and here is my build.gradle file:
plugins {
id "groovy"
id "java"
}
group "com.matthiasdenu"
version "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/releases/'
}
}
ext {
jobDslVersion = "1.77"
jenkinsVersion = "2.252"
}
sourceSets {
jobs {
groovy {
srcDirs "jobs"
compileClasspath += main.compileClasspath
}
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
}
dependencies {
compile("org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"){
// https://github.com/sheehan/job-dsl-gradle-example/issues/87
exclude group: "org.jenkins-ci.ui", module: "bootstrap"
}
}
test {
useJUnitPlatform()
}
This is the error message I'm getting:
Execution failed for task ':compileTestGroovy'.
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not find org.connectbot.jbcrypt:jbcrypt:1.0.0.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.pom
- https://repo.jenkins-ci.org/releases/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.pom
Required by:
project : > org.jenkins-ci.main:jenkins-war:2.252 > org.jenkins-ci.main:jenkins-core:2.252
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
What's odd is that the 1.0.0 artifact doesn't show up at https://repo.maven.apache.org/maven2/org/connectbot/jbcrypt/. I also noticed that the urls don't quite match either. Like if I try to get v1.0.1 it doesn't resolve either because it expects an extra "jbcrypt" for the group name.
I have this problem even when using the latest jenkins-war release (2.304).
What's going on?
You have to add the Jenkins public repository to your configuration. It contains all libraries available in the releases repository and all required dependencies.
The file exists: https://repo.jenkins-ci.org/public/org/connectbot/jbcrypt/jbcrypt/1.0.0/jbcrypt-1.0.0.jar
repositories {
mavenCentral()
maven {
url 'https://repo.jenkins-ci.org/public/'
}
}

Apply plugin configuration in init.gradle script

I want to install some packages locally for all my projects, e.g. dependency-analyse. But I need to actually configure the plugin - also in the init script.
initscript {
repositories {
jcenter()
}
dependencies {
classpath "ca.cutterslade.gradle:gradle-dependency-analyze:1.3.0"
}
}
allprojects {
apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
}
This init script works fine and applies the plugin, but unfortunately, the default setting is that the plugin fails the build. I would like to just log a warning.
For that I need to add configs:
analyzeClassesDependencies {
justWarn = true
}
analyzeTestClassesDependencies {
justWarn = true
}
but when I try to add it in the init.gradle file:
initscript {
repositories {
jcenter()
}
dependencies {
classpath "ca.cutterslade.gradle:gradle-dependency-analyze:1.3.0"
}
}
allprojects {
apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
analyzeClassesDependencies {
justWarn = true
}
analyzeTestClassesDependencies {
justWarn = true
}
}
I get an error:
FAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/<my-user>/.gradle/init.gradle' line: 13
* What went wrong:
Could not find method analyzeClassesDependencies() for arguments [init_2y9p9if69e8553k9fsvzz4a28$_run_closure1$_closure2#3e17c37a] on root project 'my-project' of type org.gradle.api.Project.
Anybody an idea of how I can apply plugin configuration?
I tried the gradle forum but didn't get any answer, so I hope to get some more help here :)
AnalyzeDependenciesPlugin will add different tasks depending on which plugin is applied to your project. For example analyzeClassesDependencies and analyzeTestClassesDependencies will be declared only when java plugin is applied (see how this plugin is implemented here : https://github.com/wfhartford/gradle-dependency-analyze/blob/master/src/main/groovy/ca/cutterslade/gradle/analyze/AnalyzeDependenciesPlugin.groovy )
So you just need to apply java plugin before you apply the AnalyzeDependenciesPlugin in your allprojects configuration closure:
allprojects {
apply plugin: "java" // <= apply Java plugin here
apply plugin: ca.cutterslade.gradle.analyze.AnalyzeDependenciesPlugin
analyzeClassesDependencies {
justWarn = true
}
analyzeTestClassesDependencies {
justWarn = true
}
}

Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2) flutter project

I have an error with lint-gradle-api.jar, I looked at other similar questions on the forums but I still have the problem.
Does anyone have an idea ?
Error running Gradle:
Exit code 1 from: C:\Users\bgbra\Documents\Flutter_apps\flutter_app\android\gradlew.bat app:properties:
Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\bgbra\Documents\Flutter_apps\flutter_app\android\app\build.gradle' line: 25
What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all artifacts for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
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.
build.gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my build.gradle file. I don't know, will it help you.
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
// global properties used in sub modules
ext {
versionCodeProp = 81100
versionNameProp = "0.8.11-dev"
versionBuild = System.getenv("BUILD_NUMBER") as Integer ?: 0
buildNumberProp = "${versionBuild}"
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
google()
}
}
Probably you shoul add maven to allprojects branch.

Gradle cannot find project (project with path $ cannot be found)

This project (example) depends on a project defined in the parent directory. It is not part of the parent directory project's build at all. However, Gradle never finds a project in any of my folders with projects in them. The parent directory contains a multiplatform multiproject library project for libGDX. I cannot call project() and find one in ANY directory so far...
FAILURE: Build failed with an exception.
* Where:
Settings file '/home/athenacadence/git/gdx-complextext/example/settings.gradle' line: 2
* What went wrong:
A problem occurred evaluating settings 'example'.
> Project with path '/../html' could not be found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
CONFIGURE FAILED
Total time: 0.124 secs
gdx-complextext/example/settings.gradle
include 'desktop', 'android', 'ios', 'html', 'core', 'ios-moe'
includeBuild(project("/../html"))
gdx-complextext/build.gradle
ext {
GROUPID = 'com.athenaeumapps.gdxcomplextext'
VERSION = '0.0.1-SNAPSHOT'
}
buildscript {
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
maven { url uri(System.getenv("INTEL_MULTI_OS_ENGINE_HOME") + "/gradle") }
}
dependencies {
classpath 'com.goharsha:gwt-opentype:0.1-SNAPSHOT'
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0'
classpath group: 'org.multi-os-engine', name: 'moe-gradle', version: '1.1.+'
}
}
allprojects {
apply plugin: "eclipse"
ext {
appName = 'gdx-complextext'
gdxVersion = '1.9.6'
roboVMVersion = '2.2.0'
}
repositories {
mavenCentral()
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
group = GROUPID
version = VERSION
}
project(":android") {
configurations {
custom
compile.extendsFrom custom
}
eclipse {
project {
name = appName + "-android"
}
}
dependencies {
compile project(':core')
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
}
}
project(":core") {
apply plugin: 'java'
apply from: '../publish.gradle'
configurations {
custom
compile.extendsFrom custom
}
eclipse {
project {
name = appName + "-core"
}
}
dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}
}
project(":desktop") {
apply plugin: 'java'
apply from: '../publish.gradle'
configurations {
custom
compile.extendsFrom custom
}
eclipse {
project {
name = appName + "-desktop"
}
}
dependencies {
compile project(':core')
}
}
project(":html") {
apply plugin: 'java'
apply from: '../publish.gradle'
configurations {
custom
compile.extendsFrom custom
}
eclipse {
project {
name = appName + "-html"
}
}
dependencies {
compile project(':core')
}
dependencies {
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
compile "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
compile "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}
}
project(":ios") {
apply plugin: 'java'
apply plugin: 'robovm'
apply from: '../publish.gradle'
configurations {
custom
compile.extendsFrom custom
}
eclipse {
project {
name = appName + "-ios"
}
}
dependencies {
compile project(':core')
compile "com.mobidevelop.robovm:robovm-rt:${roboVMVersion}"
compile "com.mobidevelop.robovm:robovm-cocoatouch:${roboVMVersion}"
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
}
}
project(":ios-moe") {
apply plugin: 'java'
apply plugin: 'moe'
apply from: '../publish.gradle'
configurations {
custom
compile.extendsFrom custom
natives
}
eclipse {
project {
name = appName + "-ios-moe"
}
}
dependencies {
compile project(':core')
compile "com.badlogicgames.gdx:gdx-backend-moe:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
}
}
EDIT
Upon trying just includeBuild, I get this:
includeBuild("${rootProject.projectDir}/../html")
Please try to use another way to obtain a project location using rootProject.projectDir then add ../html, also according to documentation there's no need to wrap into project e.g. use only includeBuild like below:
includeBuild("${rootProject.projectDir}/../html")
Another example can be found here

Gradle: How to set version from custom plugin

I've written a custom plugin (my first) which manages a "build number" which I want to include in the build.gradle "version" as so:
allprojects {
version = "1.2.3.${buildNumber}"
}
Unfortunately my plugin is never run and thus the buildNumber returned is "null".
Below is my build.gradle.
If I run "gradle showbuild" I see the right buildNumber.
If I run "gradle showInfo" the build number reported is "null".
Somehow I need to get gradle to call my plugin task 'buildInfoLoad' before the "version" value is set in allprojects. Since I'm knew to gradle I am struggling with this.
Any pointers would be most appreciated!
buildscript {
repositories {
maven {
// Access to MangoGrove
url uri('../repo')
}
maven { // aka "jcenter()"
url "https://jcenter.bintray.com"
}
}
dependencies {
// Provide the "provided" and "optional" methods for dependencies
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:3.0.3'
classpath group: 'org.mangogrove.gradle',
name: 'MangoGrove',
version: '1.0.0-SNAPSHOT'
}
}
apply plugin: 'org.mangogrove.gradle'
task showbuild(dependsOn: 'buildInfoLoad') << {
println("BI build number: $buildinfo.buildNumber")
println("BI build time: $buildinfo.buildTime")
}
task createbuild(dependsOn: 'buildInfoCreate') << {
println("BI build number: $buildinfo.buildNumber")
println("BI build time: $buildinfo.buildTime")
}
allprojects {
ext {
buildNumber = "$buildinfo.buildNumber"
}
version = "1.0.0.${buildNumber}-alpha2"
//version = "1.0.0.${buildinfo.buildNumber}-alpha2"
apply plugin: 'eclipse'
eclipse {
classpath {
downloadSources=true
//downloadJavadoc=true
}
}
}
task showInfo << {
println("Product Version is $version")
println("Product BuildNumber is $buildNumber")
}

Resources