Intellij how to set gradle property -Pname=value - gradle

Intellij: how to set gradle property -Pname=value?
build from command line:
gradlew assemble -PuseNewLibs=true
How to do this inside Intellij?
The property tells gradle to use different dependencies.

In your run configuration, you can add -PuseNewLibs=true to the Program arguments: section.

Related

ArchUnit: How to get gradle to execute the tests?

I have a gradle project where I've added the archunit-junit5 dependency and written some test classes with #ArchTests. These get picked up by IntelliJ.
How do I get gradle to execute them?
I've found the com.societegenerale.commons:arch-unit-gradle-plugin but that seems to need configuration in the gradle file.
I just want gradle to pick up the tests I already have in the test/java directory.
Gradle should pick up #ArchTests with archunit-junit5 if you useJUnitPlatform().
https://github.com/TNG/ArchUnit-Examples/tree/main/example-junit5 shows a quite minimal working example.

Gradle - publishToMavenLocal - specify custom directory

When I do a ./gradlew publishToMavenLocal it publishes to my default maven home directory of: ~/.m2.
I would instead like to publish to a custom maven repository path.
To do with with mvn command line, you can specify the command line -Dmaven.repo.local=$HOME/.my/other/repository
(See: https://stackoverflow.com/a/7071791/1174024)
But what about when publishing with Gradle? Is there a way to publish to a custom path by using an environment variable, or something similar?
You can add a system property maven.repo.local with the path.
Example:
./gradlew -Dmaven.repo.local=/path/to/local/repo publishToMavenLocal
Source: https://github.com/gradle/gradle/blob/0cb6116e150ec397f2e6c935ab4a851b48d2cf67/subprojects/dependency-management/src/main/java/org/gradle/api/internal/artifacts/mvnsettings/DefaultLocalMavenRepositoryLocator.java#L46
Note that the same thing does NOT work if you specify as a gradle project -P property. Only reads system properties.

IntelliJ "Deprecated Gradle features" - how to reproduce on command line?

When I reload my Gradle Project in IntelliJ, I get the following output:
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/7.0/userguide/command_line_interface.html#sec:command_line_warnings
However, running gradle commands on the command line, such as tasks or build does not produce this output, even with --warning-mode all.
In order to identify the deprecated features, how can I reproduce what IntelliJ is doing on the command line, or do the equivalent of passing --warning-mode all to Gradle via IntelliJ?
I'm using Gradle 7.0 with the Gradle wrapper, and IntelliJ is set to use the version in gradle-wrapper.properties.
To have IntelliJ run with the warning mode, add it to the gradle.properties file (create the file if it does not exist):
org.gradle.warning.mode=all
I have a new Java Gradle project generated with IntelliJ and run the main from the IDE. When running with this option Gradle explains what's wrong, and indicates the location in the .gradle script IntelliJ is using containing the deprecated property:
Configure project : The JavaExec.main property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the
mainClass property instead. See
https://docs.gradle.org/7.4/dsl/org.gradle.api.tasks.JavaExec.html#org.gradle.api.tasks.JavaExec:main
for more details. at
StartApplication_main__1_87e3b1xfpa17mk8z0q8rqeouu$_run_closure1$_closure2$_closure3.doCall(C:\Users\...\AppData\Local\Temp\StartApplication_main__1.gradle:23)
(Run with --stacktrace to get the full stack trace of this
deprecation warning.)
The cause of your deprecation warning may be different (like having jcenter() as suggested by #amitesh-mondal ). Adding the warning property will tell you the cause.
in settings.gradle comment out like
// jcenter() // Warning: this repository is going to shut down soon
This is going to solve the issue

How to pick up JAVA_TOOL_OPTIONS in IntelliJ Gradle build?

When I run my gradle build using a run configuration, the JAVA_TOOL_OPTIONS that I have set in my ~/.zshenv gets picked up. The result is a successful build. However, when I import the project, reload the project in the gradle tab, or change the build.gradle externally (thus causing it to be reloaded by gradle), the build fails. The failure is due to a failure to resolve plugins. I use JAVA_TOOL_OPTIONS to set "-Djavax.net.ssl.trustStore=/my/cert/location", to set the locations of some certs that are needed for these dependencies.
This is very annoying because one of the core features of IntelliJ gradle integration is auto-building the project.
Use Gradle means to set the JVM options for the Gradle daemon. For example with the Gradle System Properties:
systemProp.javax.net.ssl.trustStore=/my/cert/location

IntelliJ Idea - How to enable gradle wrapper

Importing gradle project into intelliJ IDEA : use default gradle wrapper option (not configured for the current project) is disabled.
How to solve this?
So you ask why this option is grayed out?
That because the your project doesn`t have a wrapper.
You can add a wrapper by using the task
gradle wrapper
This will add a gradle directory , a file named gradlew.bat and one named gradlew
after this you can reimport your project or
change it in your settings control + shift + s

Resources