gradle build for kotlin code - gradle

I'm trying to set up a project building Kotlin code with Gradle. I've followed instructions here on how to set up the build.gradle file but am receiving an error
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0'
}
}
apply plugin: 'kotlin'
With this I get the error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'kjsonparser'.
Could not resolve all files for configuration ':classpath'.
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0.
Required by:
project :
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0.
Could not get resource 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0/kotlin-gradle-plugin-1.2.0.pom'.
Could not GET 'https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.2.0/kotlin-gradle-plugin-1.2.0.pom'.
java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
I've also tried the "newer" way of specifing the plugin
plugins {
id "org.jetbrains.kotlin.jvm" version "1.2.0"
}
Which gives this error:
What went wrong:
Plugin [id: 'org.jetbrains.kotlin.jvm', version: '1.2.0'] was not found in any >of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact >'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.2.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Version of Gradle
gradle -version
------------------------------------------------------------
Gradle 4.4
Kotlin (and openjdk)
kotlin -version
Kotlin version 1.2.0 (JRE 1.8.0_151-8u151-b12-0ubuntu0.17.10.2-b12)
Running on Ubuntu 17.10
I've never worked with Gradle before so not sure if I'm missing anything in the build file

Try this. It works:
buildscript {
ext.kotlin_version = '1.2.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

I never use the buildscript block.
Try this instead:
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.4.31'
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.4.31'
}

Related

avro gradle plugin failing to build using gradle

I am trying to build the avro gradle plugin using gradle and even though I had set my settings.gradle as :
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
and build.gradle :
plugins {
id "com.github.davidmc24.gradle.plugin.avro" version "1.3.0"
}
repositories {
mavenCentral()
}
dependencies {
implementation "org.apache.avro:avro:1.11.0"
}
generateAvroJava {
source("${projectDir}/src/main/resources/avro")//sourcepath avrofile
}
while executing the gradle build I get the errors below:
* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.github.davidmc24.gradle.plugin.avro', version: '1.11.0'] was not found in
any of the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.github.
not sure if I am missing something that is causing it to fail. any ideas.. thanks.

Could not get unknown property 'enforcer' for extension 'enforce'

I tried to use the gradle plugin 'org.kordamp.gradle.enforcer' but get the error message "Could not get unknown property 'enforcer' for extension 'enforce'" when I start gradle (e.g. ./gradlew clean). I've tried several gradle version (6.9, 7.4, 7.5) and an older version of the plugin (0.9.0).
My project has a simple settings.gradle:
rootProject.name = 'EnforceTest'
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'org.kordamp.gradle:enforcer-gradle-plugin:0.10.0'
}
}
apply plugin: 'org.kordamp.gradle.enforcer'
enforce {
rule(ruleType: enforcer.rules.BanDulicateClasses)
}
What is the reason for the error? Any idea is appreciated :-)

gradle build failed with exception

apply plugin: 'java'
group 'com.CustomWIH'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.jbpm:jbpm-kie-services:7.20.0.Final'
}
task fatJar(type: Jar) {
baseName='jbpmTutorial'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
jbpm dependency has a dependency that is no longer available in maven repository
org.freemarker version 2.3.26 https://mvnrepository.com/artifact/org.freemarker/freemarker
C:\Users\kona\IdeaProjects\com-CustomWIH>gradle fatJar --stacktrace
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\kona\IdeaProjects\com-CustomWIH\build.gradle' line: 21
What went wrong:
Could not determine the dependencies of task ':fatJar'.
Could not resolve all files for configuration ':compile'.
Could not find org.freemarker:freemarker:2.3.26.jbossorg-1.
Searched in the following locations:
https://repo.maven.apache.org/maven2/org/freemarker/freemarker/2.3.26.jbossorg-1/freemarker-2.3.26.jbossorg-1.pom
https://repo.maven.apache.org/maven2/org/freemarker/freemarker/2.3.26.jbossorg-1/freemarker-2.3.26.jbossorg-1.jar
Required by:
project : > org.jbpm:jbpm-kie-services:7.20.0.Final
I've never ran into this issue before. What do I do in this situation?
Your dependency tree contains this transitive dependency: org.freemarker:freemarker:2.3.26.jbossorg-1, which is not found in Maven Central.
The reason it does not exist in Maven Central is that it is not the normal version of freemarker, but a JBoss patched version, which can be seen from the version of the dependency 2.3.26.jbossorg-1.
Googling for org.freemarker:freemarker:2.3.26.jbossorg-1 took me to this Maven repository: https://repository.jboss.org/nexus/content/groups/public/
The solution would be to add this Maven repository to your build.gradle like this:
repositories {
mavenCentral()
maven {
url "https://repository.jboss.org/nexus/content/groups/public/"
// OR this one, as suggested by jb-nizet
// url "https://maven.repository.redhat.com/ga/"
}
}

My Plugin is not searched in maven central repository even though I have added in buildscript's repositories

My Plugin is not searched in maven central repository when i start running my build.gradle file.
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
}
plugins {
id 'net.sf.jbddi.jbddi-core' version '1.0.1'
}
apply plugin: 'java'
apply plugin: 'maven'
I am getting the below error.
What went wrong:
Plugin [id: 'net.sf.jbddi.jbddi-core', version: '1.0.1'] was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
Plugin Repositories (could not resolve plugin artifact 'net.sf.jbddi.jbddi-core:net.sf.jbddi.jbddi-core.gradle.plugin:1.0.1')
Searched in the following repositories:
Gradle Central Plugin Repository
the buildscript dependencies are for Gradle plugins only;
just define the repository outside of that block:
repositories {
mavenCentral()
}

Gradle fails to resolve spring dependency

I am trying to build my project with the following build.gradle file.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath('org.springframework.boot:spring-boot-gradle-plugin:1.2.1.RELEASE')
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
repositories {
maven {
url 'https://repo.spring.io/milestone'
}
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-mongodb:1.2.2.RELEASE')
compile('org.springframework.data:spring-data-mongodb:1.7.0.RC1')
compile('org.springframework.cloud:spring-cloud-spring-service-connector')
compile('org.springframework.cloud:spring-cloud-cloudfoundry-connector')
compile 'org.springframework:spring-test:4.1.5.RELEASE'
compile 'de.grundid.opendatalab:geojson-jackson:1.3'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.5.1'
compile 'org.apache.httpcomponents:httpclient:4.4'
testCompile('junit:junit')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.3'
}
I added the milestone repository because I need the spring-data-mongodb 1.7.0.RC1 dependency. However, there seems to be something wrong with the references of the parent-poms because gradle is unable to fetch the following dependency: org.springframework.data.build:spring-data-parent:1.6.0.RC1
It exits with the following error:
Could not find org.springframework.data.build:spring-data-parent:1.6.0.RC1.
Searched in the following locations:
https://repo.spring.io/milestone/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.pom
https://repo.spring.io/milestone/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.jar
https://repo1.maven.org/maven2/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.pom
https://repo1.maven.org/maven2/org/springframework/data/build/spring-data-parent/1.6.0.RC1/spring-data-parent-1.6.0.RC1.jar
The output of the gradlew build --debug command can be found here: http://pastebin.com/seYRMFQP
The command additionally produced the following output to stdout: http://pastebin.com/atcWQsKF
I already tried to clean my local gradle cache but it did not resolve the problem.
Sorry for the inconvenience, the artifact is currently misplaced in the release repository, though it should be in milestone.
We'll move it to milestone asap. Until that happens please add the release repository url 'https://repo.spring.io/release' to your build.
seems the repositories you defined in your build do not contain the libraries you're looking for. but it seems the lib is available in jcenter. to add jcenter add the following snippet to your build.gradle file:
repositories {
jcenter()
}
cheers,
René

Resources