Change default option of Intellij IDEA gradle plugin - gradle

Everytime I check out and open a project in Intellij I need to change the gradle plugin setting "Use Gradle from" from the default "'gradle-wrapper.properties' file" to "'wrapper' task in Gradle build script"
Is there a way in Intellij 2020 to make the shown option the default?
Reason I am asking: Generated gradle-wrapper files are not in our VCS, but the build.gradle is, and it has the wrapper task configured with the desired version. So when I check out a project, Intellij does not find gradle.properties (and neither can download gradle from web, as that is blocked). I then have to change the option "Use Gradle From" manually each time.
Another solution I tried is to automatically run a script when opening a module, which would run gradle wrapper with a fixed gradle version for the module, hence generating the missing wrapper files. But I find no possibility in Intellij to trigger that upon import..

It is not possible to change this setting for all projects. Please vote for this request: IDEA-215792.

Related

How can I set a project as trusted when using the gradle :runIde task during IntelliJ Plugin Development

the documentation shows that I can configure this via the gui here: https://www.jetbrains.com/help/idea/project-security.html
Each time I have gradle perform :runIde it launches a new IDE instance and I have to reconfirm the trusted project directory.
Is there a gradle flag or setting somewhere in the plugin project to set this once for all?
I am using a kotlin build.gradle.kts file
*I have configured the trusted root in my 'Parent' IntelliJ IDEA that launches the task, but it seems, is sometimes not carried over. Alternatively I would like this to be available when operating from the CLI aswell.
*I am using the :clean command alongside the :runIde command, would this affect the settings being erased?

How to set working dir for Gradle task in Intellij?

The IntelliJ Run/Debug configuration UI used to have a field for "Working dir". However, the UI seems to have changed in a recent version, and I can't find that field any more.
I've tried adding --project-dir ../path to the "Tasks and arguments" field, but that doesn't do anything.
How do I set the working dir for Gradle tasks?
You can specify the project in Gradle project field of the run configuration:

IDEA and how to disable gradle wrapper generation?

I am new to IJ IDEA and Gradle KTS.
I created the kts by hand and imported it into IJ. IDEA has generated the gradle wrapper, but I do not want this. If I delete the gradle wrapper and associated directory, IDEA prompts me to 'import changes' from gradle, which then creates the gradle wrapper again...
My question is how to prevent this behavior? ie prevent gradle wrapper generation?
I found documentation for the Wrapper task, and the option to point to a local install using distributionUrl. But that doesnt seem to prevent the generation of the gradle wrapper, only bypass the download...
Also I can not find any options in IDEA to disable this behavior.
btw I do understand the benefits of the wrapper.
Thanks.
IntelliJ IDEA EAP 2019.2
macOS 10.12.4
gradle 5.2.1
kotlin DSL 1.1.3
Disabling access to the download directory seems to work:
mkdir -p ~/.gradle/wrapper/dists && chmod -rwx ~/.gradle/wrapper/dists
Note that this prevents the wrapper to work at all (which is exactly what I want) and causes error messages, but as far as I can see it does the job and the project simply has to be configured to use the system gradle distribution after import.

Intellij issue resolving dependency for spring kotlin

Intellij is giving me errors all around for brand new kotlin/spring project and I cannot build or run the project from the IDE.
If I do it from the command line however, there are no issues and I can build and run the app.
'classpath' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'
'apply' in 'org.gradle.api.plugins.PluginAware' cannot be applied to '(['plugin':java.lang.String])'
Cannot access class 'java.lang.String'. Check your module classpath for missing or conflicting dependencie
Type mismatch.
Required:
java.lang.String
Found:
kotlin.String
Any ideas to what may be the issue?
I tried Kotlin multiplatform JVM type mismatch in InteliJ but doesn't seem to fix the issue.
UPDATE:
Cleared gradle caches, reinstalled Intellij, Import project that was created from start.spring.io with Gradle and Kotlin selected.
Using default gradle wrapper and project jdk (the path says jre)? gives me an error. Open gradle settings just opens the file explorer.
Using default gradle wrapper and machine local JDK same issues with the dependencies from above.
This issue comes up if you set up your own module inside IntelliJ and you think that since you are doing a Kotlin (Maven) project, the SDK should be set to Kotlin. Wrong!
The problem is shown in the first image. The project SDK is set to Kotlin.
Change it to Java. Probably any 8+ Java will be good enough.
This solves the IDE errors and the compiler errors as well.
Unset KOTLIN_HOME and other Kotlin- or Java-related settings you may have in your environment (env to check, unset NAME to unset.)
Then kill any Gradle daemon still running (pkill -f GradleDaemon) and test your Gradle build from the terminal. If all goes well, remove the .idea directory; restart IDEA, making sure to run it without the stray environment variables (for example, launch idea.sh from the terminal where you unset them); and re-import your project, with the choice of using the default Gradle wrapper.
If you need to use standalone Kotlin versions, installed for example through SDKMAN, consider taking the SDKMAN activation lines out of your shell init file (.bashrc for Bash) and into a standalone script (say, ~/bin/sdkman) that will also change your shell prompt (PS1 in Bash) to remind you that you have entered a SDKMAN-managed CLI session.

How to load a specific build.gradle/gradle.properties for default build process

I have three build.gradle with different name under the same directory
dev.build.gradle
uat.build.gradle
prd.build.gradle
I have 4 issues
"gradle build" will just use build.gradle only to start the java plugin build task, but "gradle -b dev.build.gradle" will not start the java plugin build task
gradle --help seems not having an option to load a specific gradle.properties. There is another way that creating three directories(dev, uat, prd) under the project root and putting a responding build.gradle version in it. finally, start the java plugin build process. I dont like this because I just want build.gradle or gradle.properties files in the same directory
how to copy files in gradle without explicitly specify task name in the command line(gradle build copy).
ad 1. The correct command is gradle -b dev.build.gradle build.
ad 2. If you want to use properties files other than build.gradle, you'll have to do it on your own (e.g. using the java.util.Properties class). There is also a third-party properties plugin.
ad 3. This doesn't seem to be a question.
ad 4. You should turn this into a separate question.

Resources