How can I initialize Gradle projects in non-English systems? - java

I am trying to use Gradle on my Windows machine. The command I want to be able to use is:
gradle init --type java-application
But here is the error I get when I run this command on Powershell (or cmd):
> Task :init FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':init'.
> The requested build type 'java-application' is not supported. Supported types:
- 'basic'
- 'cpp-application'
- 'cpp-library'
- 'groovy-appl²cat²on'
- 'groovy-gradle-plugin'
- 'groovy-l²brary'
- 'java-appl²cat²on'
- 'java-gradle-plugin'
- 'java-l²brary'
- 'kotlin-appl²cat²on'
- 'kotlin-gradle-plugin'
- 'kotlin-l²brary'
- 'pom'
- 'scala-appl²cat²on'
- 'scala-l²brary'
- 'swift-application'
- 'swift-library'
As seen in the output, there is probably an encoding issue here. Because
java-appl²cat²on
is displayed as a possible type.
I used versions 6.9 and 7.0.2 and the results are the same. My system language is Turkish but I also use Git, Maven etc. without any issues.
Here is the output of gradle --version in case it is useful:
------------------------------------------------------------
Gradle 6.9
------------------------------------------------------------
Build time: 2021-05-07 07:28:53 UTC
Revision: afe2e24ababc7b0213ccffff44970aa18035fc0e
Kotlin: 1.4.20
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 1.8.0_231 (Oracle Corporation 25.231-b11)
OS: Windows 10 10.0 amd64

Update: Issue #17383 has been fixed and is targeted for Gradle 7.2.
You may hit a bug in Gradle. I was able to reproduce the issue by forcing tr-TR locale in environment variable JAVA_TOOL_OPTIONS. I filed a bug in the Gradle issue tracker to have this checked: Build init plugin is locale sensitive.
As a workaround, you could force English locale for project initialization, in Powershell:
PS> $env:JAVA_TOOL_OPTIONS="-Duser.language=en -Duser.country=US"
PS> gradle.bat init --type java-application
Picked up JAVA_TOOL_OPTIONS: -Duser.language=en -Duser.country=US
Select build script DSL:
1: Groovy
2: Kotlin
Enter selection (default: Groovy) [1..2]

Related

Set test-framework with gradle init

------------------------------------------------------------
Gradle 7.1
------------------------------------------------------------
Build time: 2021-06-14 14:47:26 UTC
Revision: 989ccc9952b140ee6ab88870e8a12f1b2998369e
Kotlin: 1.4.31
Groovy: 3.0.7
Ant: Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM: 1.8.0_292 (Amazon.com Inc. 25.292-b10)
OS: Windows 10 10.0 amd64
Do I have a wrong understanding?
Based on the article:
https://docs.gradle.org/7.1/samples/sample_building_java_applications_multi_project.html
When creating a multi module project, I'm NOT prompted about the --test-framework when running gradle init interactive.
When I specify the parameters from CLI like:
gradle init --type java-application --dsl groovy --project-name myapp --package myapp --split-project --test-framework junit
I also get junit-jupiter(Junit5) as test-framework.
buildSrc\src\main\groovy\myapp.java-common-conventions.gradle contains
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
No change, when I use different --test-framework values.
The generated JUnit examples in the sub-projects always using:
import org.junit.jupiter.api.Test;
Any hints? Thanks in advance

Pending gitlab-ci test job using gradle and kotlin

I'm trying to build a kotlin library using gradle (wrapped) and gitlab-ci. If i execute commands on my machine everything works fine but gitlab-ci test job doesnt not end and is pending on Task :test.
I'm using basic gitlab-ci inspired by this example.
image: gradle:5.6.2-jdk8
stages:
- build
- test
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build-latest:
stage: build
script:
- ./gradlew assemble
only:
- master
- tags
test:
stage: test
script:
- ./gradlew check
and that's gitlab-ci ( 12.2.5 ) output
Running with gitlab-runner 12.2.0 (a987417a)
on autoscale-runner eaccdfe9
Using Docker executor with image gradle:5.6.2-jdk8 ...
Pulling docker image gradle:5.6.2-jdk8 ...
Using docker image sha256:5eacc675d8626e3db6a6c4030fc817113f536f565ecd23b7f5aec7e5e5bfcc53 for gradle:5.6.2-jdk8 ...
Running on runner-eaccdfe9-project-769-concurrent-0 via runner-eaccdfe9-autoscale-1570629641-a91eb9db...
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/platform/libraries/kafka2rest/.git/
Checking out 69a3b20e as master...
Removing .gradle/
Removing build/
Skipping Git submodules setup
Checking cache for default-1...
Downloading cache.zip from http://10.164.0.3:9000/runner/runner/eaccdfe9/project/769/default-1
Successfully extracted cache
$ export GRADLE_USER_HOME=`pwd`/.gradle
$ ./gradlew -v
Welcome to Gradle 5.6.2!
Here are the highlights of this release:
- Incremental Groovy compilation
- Groovy compile avoidance
- Test fixtures for Java projects
- Manage plugin versions via settings script
For more details see https://docs.gradle.org/5.6.2/release-notes.html
------------------------------------------------------------
Gradle 5.6.2
------------------------------------------------------------
Build time: 2019-09-05 16:13:54 UTC
Revision: 55a5e53d855db8fc7b0e494412fc624051a8e781
Kotlin: 1.3.41
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM: 1.8.0_222 (AdoptOpenJDK 25.222-b10)
OS: Linux 4.15.0-1044-gcp amd64
$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.222-b10, mixed mode)
$ ./gradlew check
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :compileKotlin
> Task :compileJava NO-SOURCE
> Task :processResources
> Task :classes
> Task :compileTestKotlin
> Task :compileTestJava NO-SOURCE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test
What's wrong with this? Is there any standard or template for building kotlin with gradle and gitlab-ci?
Edit
I've found the pending test suite. It contains 3 test, any of them create new instance of controller that has the same start() method. The start() method launch a new thread. If just one test runs it works with successful gitlab-ci termination, if two or more test run it doesn't and it remains in pending state. In tests I use semaphores.
Tests still work locally.

How to debug java_library rule in a bazel build?

I dug around option and source code but still unsure how to debug a bazel build, java specifically.
Also anyone know how I can change bazel, build it locally and use it on builds to verify. I found bazel invocation:
exec -a "$0" "${BAZEL_REAL}" "$#"
where BAZEL_REAL is a binary: /usr/local/Cellar/bazel/0.15.2/libexec/bin/bazel-real
But this doesn't explain closely how it starts and how I can debug it...
Like is it possible to jump in and debug com.google.devtools.build.lib.bazel.rules.java.BazelJavaLibraryRule while building my code? Like if I build my code with Maven, I can do mvnDebug.
bazel build -s
➜ bazel git:(master) ✗ bazel build //examples/java-native/src/main/java/com/example/myproject:hello-world -s
BAZEL_REAL==/usr/local/Cellar/bazel/0.15.2/libexec/bin/bazel-real
INFO: Analysed target //examples/java-native/src/main/java/com/example/myproject:hello-world (15 packages loaded).
INFO: Found 1 target...
Target //examples/java-native/src/main/java/com/example/myproject:hello-world up-to-date:
bazel-bin/examples/java-native/src/main/java/com/example/myproject/hello-world.jar
bazel-bin/examples/java-native/src/main/java/com/example/myproject/hello-world
INFO: Elapsed time: 4.943s, Critical Path: 0.29s
INFO: 0 processes.
INFO: Build completed successfully, 2 total actions
nevermind me, https://www.bazel.build/contributing.html#setting-up-your-coding-environment has the info I need.
Basically for starter
bazel --host_jvm_debug build //:*
the order of args are significant. For example below will NOT work
bazel build //:* --host_jvm_debug
To debug worker's jvm, get the command with bazel build -s, then append the remote debug startup opts.

Issue in Jenkins installation plugins

I am facing issue while installing any of the Jenkins plugins suggested.
Actually after downloading,Jenkins.war file(which is latest 2.141) when i tried to execute the jar with
java -jar jenkins.war so it gave me an error of Jenkins require java 8 but you are using 10. Also,it says that java class version 54.0 is running,but it requires java 52.0.
But I was able to resolve this issue by setting --enable-future-java flag.
java -jar jenkins.war --enable-future-java flag
Now,after writing this command,jenkins is up and running but i am unable to install the plugins.
Also,im cmd prompt after the Jenkins is upa d running.There is one error also.
PFB :-
Sep 17, 2018 4:38:49 PM hudson.WebAppMain$3 run
INFO: Jenkins is fully up and running
[31mSep 17, 2018 4:39:02 PM hudson.model.UpdateSite updateData
SEVERE: ERROR: SHA-512 based signature in the update center doesn't match with the certificate in 'update site 'default''
[0mSep 17, 2018 4:39:02 PM hudson.model.AsyncPeriodicWork$1 run
INFO: Finished Download metadata. 15,407 ms
You need to add a flag which allows starting Jenkins with unsupported Java versions. You can do some google research on this.
If we change the Jenkins war file version from 2.141 to 2.814 then it is suitable with Java 10 and works fine for plugins installation of Jenkins

gradle: not installed (cordova requirements)

i tried to type :
cordova requirements
and it is give result as :
Android Studio project detected
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26
Gradle: not installed
Cannot read property 'length' of undefined
(node:2392) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
at _fulfilled (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
at flush (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:2392) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2392) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
so i tried to install gradle manually. And after the gradle was installed, i tried to type:
gradle -v
and then it is give result as :
------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC
Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_162 (Oracle Corporation 25.162-b12)
OS: Windows 7 6.1 amd64
it means the gradle was installed. But when i try to cek the requirements again with type :
cordova requirements
it still give me same result like before as :
Android Studio project detected
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26
Gradle: not installed
Cannot read property 'length' of undefined
(node:2392) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
at _fulfilled (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
at flush (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:2392) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2392) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
And after that, i tried again to install gradle in cmd with command :
npm install gradle
and it is give result as :
+gradle#1.0.9
added 20 packages from 14 contributors in 182.961s
[!] 13 vurnerabilities found [4232 packages audited]
severity 2 low | 11 moderate
run 'npm audit' for more detail
and then i tried again to check requirements, and it is gave me same result as:
cordova requirements
it still give me same result like before as
Android Studio project detected
Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-27,android-26
Gradle: not installed
Cannot read property 'length' of undefined
(node:2392) UnhandledPromiseRejectionWarning: CordovaError: Some of requirements check failed
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\src\cli.js:414:27
at _fulfilled (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:787:54)
at self.promiseDispatch.done (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:816:30)
at Promise.promise.promiseDispatch (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:749:13)
at C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:557:44
at flush (C:\Users\dell\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\q\q.js:108:17)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
(node:2392) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:2392) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code
when i check again the version of gradle with type :
gradle -v
it still give the same version as 4.7 with the result :
------------------------------------------------------------
Gradle 4.7
------------------------------------------------------------
Build time: 2018-04-18 09:09:12 UTC
Revision: b9a962bf70638332300e7f810689cb2febbd4a6c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_162 (Oracle Corporation 25.162-b12)
OS: Windows 7 6.1 amd64
my question is, why the gradle still not installed?
please help me, i dont know how to fix it again.
Thank you !
im use:
cordova : 8.0.0
node :8.11.2
java jdk : 1.8.0
gradle : 4.7
windows 7 64-bit
Kindly add path to your system variable. i.e
Open system -> advanced -> Environment Variable
under system variable section click on path and then click on edit button
their add your path to gradle/bin.

Categories

Resources