How to debug java_library rule in a bazel build? - java

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.

Related

The module has not been deployed : Tomcat 9

I am using Netbeans 8.2 and Tomcat 9. I just create a new project and trying to run but every time it shows this error and for existing projects also it is running another PC smoothly.
Can you please suggest something for the solution -
ant -f "C:\\Users\\UserName\\Documents\\NetBeansProjects\\Test" -Dnb.internal.action.name=run -Ddirectory.deployment.supported=true -DforceRedeploy=false -Dnb.wait.for.caches=true "-Dbrowser.context=C:\\Users\\Rifat Tanjir\\Documents\\NetBeansProjects\\Test" run
init:
deps-module-jar:
deps-ear-jar:
deps-jar:
library-inclusion-in-archive:
library-inclusion-in-manifest:
compile:
compile-jsps:
In-place deployment at C:\Users\UserName\Documents\NetBeansProjects\Test\build\web
deploy?config=file%3A%2FC%3A%2FUsers%2FRIFATT%7E1%2FAppData%2FLocal%2FTemp%2Fcontext4316755968276891464.xml&path=/Test
Server returned HTTP response code: 500 for URL: http://localhost:80/manager/text/deploy?config=file%3A%2FC%3A%2FUsers%2FRIFATT%7E1%2FAppData%2FLocal%2FTemp%2Fcontext4316755968276891464.xml&path=/Test
C:\Users\UserName\Documents\NetBeansProjects\Test\nbproject\build-impl.xml:1045: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 14 seconds)

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

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]

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

Sonar on Travis: ERROR You must define the following mandatory properties for 'Unknown'

I'm trying to setup SonarQube on Travis for a Java project by following Travis documentation https://docs.travis-ci.com/user/sonarqube/
My resulting my .travis.yml file is as follows:
sudo: required
cache:
directories:
- $HOME/.m2
language: java
services:
- docker
jdk:
- oraclejdk8
os:
- linux
env:
matrix:
- NEO_VERSION=3.0.9
WITH_DOCKER=true
EXTRA_PROFILES=-Pwith-neo4j-io
- NEO_VERSION=3.1.2
WITH_DOCKER=true
EXTRA_PROFILES=-Pwith-neo4j-io
addons:
sonarqube:
organization: ${SONAR_ORGANIZATION}
token:
secure: ${SONAR_TOKEN}
branches:
- master
- sonarqube
before_script:
script:
- build/run.sh
- sonar-scanner
install: true
after_success:
- mvn clean test jacoco:report coveralls:report
- "[ ${TRAVIS_PULL_REQUEST} = 'false' ] && [[ ${TRAVIS_BRANCH} = 'master' ]] && mvn clean deploy -DskipTests --settings ./deploy-settings.xml"
My resulting sonar-scanner.properties file is:
# must be unique in a given SonarQube instance
sonar.projectKey=liquigraph
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Liquigraph
sonar.projectVersion=1.0
# Set modules IDs
sonar.modules=liquigraph-cli,liquigraph-core,liquigraph-maven-plugin,liquigraph-spring-boot-starter,liquigraph-examples
# Modules inherit properties set at parent level
sonar.sources=src
sonar.sourceEncoding=UTF-8
sonar.language=java
But when I commit and Travis start building, sonar job fails with following logs:
. . .
$ sonar-scanner
INFO: Scanner configuration file: /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 2.8
INFO: Java 1.8.0_111 Oracle Corporation (64-bit)
INFO: Linux 4.4.0-51-generic amd64
INFO: User cache: /home/travis/.sonar/cache
. . .
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 13.770s
INFO: Final Memory: 64M/505M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
I did put my sonar-scanner.properties in the root of my project folder. Why travis cannot find and instead is using /home/travis/.sonarscanner/sonar-scanner-2.8/conf/sonar-scanner.properties?
If your project is a Maven project, then simply use the Scanner for Maven: mvn sonar:sonar
Look at https://about.sonarqube.com/get-started/ for details.
If you really want to use the SonarQube Scanner, then your issue is that you are not using the correct name for the configuration file. It should be sonar-project.properties.

Jenkins: Duplicate building of jars in a single build

I am using Jenkins 1.596 along with Maven 3.1.1. I have multiple branches in my repository and I am using following goals for build:
'-T 5 clean install'
When I start the build, it shows following log:
Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/<my_job>/workspace
> git rev-parse --is-inside-work-tree # timeout=10
....
[workspace] $ /usr/local/apache-maven/apache-maven-3.1.1/bin/mvn -s /var/lib/jenkins/.m2/settings.xml -T 5 clean install
[INFO] Scanning for projects...
It then shows the projects and Reactor build order. It executes the tests successfully and builds all the jars. Following Success message gets displayed after completion of build:
BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:39.752s (Wall Clock)
[INFO] Finished at: Wed Apr 15 00:02:57 BST 2015
[INFO] Final Memory: 104M/406M
Now, the issue is, just after this success message, it repeats the whole build again. It starts scanning all the poms, downloads jars, executes tests and again, I can see the success message. Following is the starting trace of unwanted build:
Parsing POMs
[workspace] $ java -Xmx1024M -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-agent-1.6.jar:/usr/local/apache-maven/apache-maven-3.1.1/boot/plexus-classworlds-2.5.1.jar:/usr/local/apache-maven/apache-maven-3.1.1/conf/logging jenkins.maven3.agent.Maven31Main /usr/local/apache-maven/apache-maven-3.1.1 /var/cache/jenkins/war/WEB-INF/lib/remoting-2.49.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven31-interceptor-1.6.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.6.jar 54000
<===[JENKINS REMOTING CAPACITY]===>channel started
Due to this, the whole build takes twice as much time. I have disabled archiving but that doesn't seem to have affected this. Can anyone please let me know what am I doing wrong here?
Thanks in advance.
I finally managed to figure out the cause of this. Apparently, the 'Pre Steps' was enabled in jenkins which was doing mvn clean install and then the actual build was configures to start which in turn, was doing the same thing :)
I have removed the pre step and it is now building in half amount of time compared to earlier builds.
Hope this helps someone :)

Categories

Resources