Kotlin-DSL | Migrating build logic from Groovy to Kotlin | Plugin library
kandi X-RAY | Kotlin-DSL Summary
kandi X-RAY | Kotlin-DSL Summary
Migrating build logic from Groovy to Kotlin
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Kotlin-DSL
Kotlin-DSL Key Features
Kotlin-DSL Examples and Code Snippets
Community Discussions
Trending Discussions on Kotlin-DSL
QUESTION
When I create an empty project with Gradle Kotlin DSL, even without any modifications, it would prompt Cannot access script base class 'org.gradle.kotlin.dsl.KotlinBuildScript'. Check your module classpath for missing or conflicting dependencies
The project can run, but the syntax highlighting and autocompletion for build.gradle.kts
don't work.
- https://github.com/gradle/kotlin-dsl-samples/issues/1308
- Changing gradle executable to
gradle-kotlin-dsl-5.2-20190122225509+0000-all.zip
- Changing gradle executable to
- https://youtrack.jetbrains.com/issue/KT-38296
- Remove empty SDKs in Project structure dialog
- Invalidate caches and restart
- Reinstalling Java 11
brew install java11
- Switching to official oracle JDK 15
brew install oracle-jdk
- https://youtrack.jetbrains.com/issue/KT-41141
- Re-adding SDKs in the SDK menu
- Adding
/Kotlin/kotlinc/lib
to Kotlin SDK's classpath
- http://youtrack.jetbrains.com/issue/IDEA-245027
- Deleting the cache folder manually
ANSWER
Answered 2021-Jan-21 at 16:25Answer credit to @AlexeyBelkov - Answered here: https://youtrack.jetbrains.com/issue/KTIJ-893
The syntax highlighting feature worked after:
- Delete
~/.gradle/caches
- Delete
~/Library/Application\ Support/Library/JetBrains/IntelliJIdea2020.3
- Delete
/.gradle
- Delete
/.idea
- Start IDEA and reimport the project.
QUESTION
I have been trying to follow GitHub tutorial to publish a package. The problem is that I get the following error when trying to run Gradle:
...ANSWER
Answered 2021-May-22 at 12:56You did not provide the type of publication, so you use just a basic Publication
. from()
is a function of MavenPublication
, so you need to explicitly specify that you need a MavenPublication
:
QUESTION
I'm new to gradle, but recently I wanted to use Kotlin-Jupyter notebook for a project.
I followed the instructions, I cloned the repo at https://github.com/Kotlin/kotlin-jupyter...
Throughout my struggles, I have gone through a whopping 5-6 errors, all of which have taken days on end to fix. It has quite literally been a nightmare.
I am getting this new error when typing in the command gradlew install
, it is an internal exception:
ANSWER
Answered 2021-Apr-10 at 22:32Using a JDK version that isn't 16 (I used JDK 15) should solve the problem. Also, make sure you change all of your environment variables and relaunch whatever command-line you are using.
QUESTION
I want to create an executable jar with gradle (kotlin-dsl) and I want to give it a custom name. For the executable jar I'm using the spring boot plugin and ./gradlew :app1:assemble
:
ANSWER
Answered 2021-Mar-14 at 08:46assemble
is a lifecycle task which means that it doesn’t create anything. Its role is to trigger other tasks that it depends upon and that do have some output. You can see those tasks by running your build with --console=plain
.
The task that creates the Spring Boot fat jar is named bootJar
. As you can see from its javadoc, it’s a customization of Gradle’s Jar
and can be configured in the same way:
QUESTION
I'm trying to simplify some of my Gradle builds. A typical build.gradle.kts
looks like
ANSWER
Answered 2021-Mar-03 at 22:40Looks like you're creating an extension function on KotlinBuildScript
which may or may not be the issue. Regardless, there's no need for extension functions since you can just use the DSL directly.
Gradle calls the shared build logic convention plugins: https://docs.gradle.org/current/samples/sample_convention_plugins.html#compiling_convention_plugins
So your Example.kt
would become kotlin-conventions.gradle.kts
:
QUESTION
I am trying to set up an AmazonConfig file for my own project to get better with Spring and AWS but I can not figure out how to import the right AWS dependency for Gradle to make it work.
build.gradle.kt
...ANSWER
Answered 2021-Mar-03 at 21:18A discussion on how to setup a gradle file for AWS Services is located here:
https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/setup-project-gradle.html
This doc is for AWS for Java V2 (which Amazon recommends using). Follow that doc and you will learn how to setup a gradle file successfully,
If you want to learn about using a Spring Boot app and AWS, try following this document that walks you through building a Spring BOOT app that uses AWS SDK for Java V2. It then teaches you how to invoke various AWS Services and then how to deploy the sample app to the cloud.
QUESTION
There are several questions here on Stackoverflow regarding the Kotlin compiler warning when different versions of Kotlin jars are mixed in the classpath.
This question is a different one and concerns the situation when you are developing Gradle plugins using Kotlin. When you have at least one of the following:
kotlin-dsl
plugin is applied;java-gradle-plugin
plugin is applied;gradleApi()
dependency is added;gradleKotlinDsl()
dependency is added;
And you have Kotlin plugin like kotlin("jvm") version "1.4.10"
, e.g.:
ANSWER
Answered 2020-Nov-13 at 22:01The only way I found to fix this problem is to remove incorrect dependencies before incorrect configurations got resolved. Here is a part of my build.gradle.kts:
QUESTION
I am facing a problem with two existing gradle projects that worked fine a couple of months ago but that show now an annoying error in the buildSrc folder, where I use the org.gradle.api.JavaVersion constant.
The project compiles correctly and is imported to IntelliJ. I can also run it so I guess everything is working but of course I don't like to get an error thrown into my face ;)
Here are both example projects:
They are both a multi-project with a core, desktop and android project. In both projects I use a buildSrc folder to define the versions in a common place for the entire project.
For whatever reason, IntelliJ is now showing an error "unresolved reference JavaVersion" in the Dependencies.kt/versions.kt file.
The build.gradle.kts of the buildSrc folder looks like this:
...ANSWER
Answered 2020-Nov-13 at 11:10This is an Intellij IDEA 2020.2 bug: https://youtrack.jetbrains.com/issue/KT-40683. Dependencies are unresolved in the buildSrc
module, when you also have an Android module in the project.
As a possible workaround, please use IDEA 2020.1.
QUESTION
Kotlin 1.4.0 is stable now. Therefor, I wanted to update my multi module Android project to use it. I set IDEA to use Kotlin plugin 1.4.0-release-IJ2020.2-1 and in my buildSrc build.gradle.kts using Kotlin DSL, I'm loading Kotlin for the jvm like this:
...ANSWER
Answered 2020-Sep-02 at 13:46Maybe you should add the Kotlin standard lib to your dependencies explicitly?
QUESTION
I am migrating certain Gradle project from the Groovy to the Kotlin DSL.
I am using the kotlin-dsl plugin and configuring Spring Boot as follows:
...ANSWER
Answered 2020-Jun-08 at 09:12The Gradle user guide for the Kotlin DSL Plugin describes it like this:
The Kotlin DSL Plugin provides a convenient way to develop Kotlin-based projects that contribute build logic. That includes buildSrc projects, included builds and Gradle plugins.
Your Spring Boot application does not contribute build logic and you probably shouldn't be using the plugin for it. If you were developing a Gradle plugin in Kotlin, then it would make more sense. And in that case you should be working against the same version of the Gradle API for the Kotlin DSL that is provided by the version you are building with, as targeting another version can be a bit tricky.
I would remove the plugin and instead be explicit about your configuration. You will need to put a few more lines in your build files, but this way the complication classpath won't be polluted by the DSL stuff that you don't need anyway.
It also means you need to hard-code the Kotlin version, but this is a good thing as you would otherwise rely on whatever happens to be included in the version of Gradle you are building with.
For example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Kotlin-DSL
STEP 1 :
STEP 2 :
STEP 3 :
STEP 4 :
STEP 5 :
STEP 6 :
STEP 7 : :point_left:
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page