Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Gradle support #609

Merged
merged 17 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions debug/debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
FROM golang:1.19 as builder
WORKDIR /analyzer-lsp

COPY ../cmd /analyzer-lsp/cmd
COPY ../engine /analyzer-lsp/engine
COPY ../output /analyzer-lsp/output
COPY ../jsonrpc2 /analyzer-lsp/jsonrpc2
COPY ../lsp /analyzer-lsp/lsp
COPY ../parser /analyzer-lsp/parser
COPY ../provider /analyzer-lsp/provider
COPY ../tracing /analyzer-lsp/tracing
COPY ../external-providers /analyzer-lsp/external-providers
COPY ../go.mod /analyzer-lsp/go.mod
COPY ../go.sum /analyzer-lsp/go.sum
COPY ../Makefile /analyzer-lsp/Makefile

# Install delve (go debugger)
COPY ../cmd /analyzer-lsp/cmd
COPY ../engine /analyzer-lsp/engine
COPY ../event /analyzer-lsp/event
COPY ../output /analyzer-lsp/output
COPY ../jsonrpc2 /analyzer-lsp/jsonrpc2
COPY ../jsonrpc2_v2 /analyzer-lsp/jsonrpc2_v2
COPY ../lsp /analyzer-lsp/lsp
COPY ../parser /analyzer-lsp/parser
COPY ../provider /analyzer-lsp/provider
COPY ../tracing /analyzer-lsp/tracing
COPY ../external-providers /analyzer-lsp/external-providers
COPY ../go.mod /analyzer-lsp/go.mod
COPY ../go.sum /analyzer-lsp/go.sum
COPY ../Makefile /analyzer-lsp/Makefile

RUN go install github.com/go-delve/delve/cmd/dlv@latest

FROM registry.access.redhat.com/ubi9/ubi-minimal:latest as yq-builder
RUN microdnf install -y wget tar xz gzip && \
microdnf clean all
ARG TARGETARCH
ARG YQ_VERSION="v4.40.5"
ARG YQ_BINARY="yq_linux_${TARGETARCH}"
RUN wget "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz" -O - | tar xz && \
mv ${YQ_BINARY} /usr/bin/yq

RUN go build -gcflags="all=-N -l" -o konveyor-analyzer ./cmd/analyzer/main.go
RUN go build -gcflags="all=-N -l" -o konveyor-analyzer-dep ./cmd/dep/main.go
RUN cd external-providers/generic-external-provider && go mod edit -replace=github.com/konveyor/analyzer-lsp=../../ && go build -gcflags="all=-N -l" -o generic-external-provider main.go
Expand Down
132 changes: 132 additions & 0 deletions demo-dep-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,138 @@
- konveyor.io/dep-source=open-source
- konveyor.io/language=java
prefix: file:///root/.m2/repository/org/yaml/snakeyaml/1.28
- fileURI: file:///analyzer-lsp/examples/gradle-multi-project-example/build.gradle
provider: java
dependencies:
- name: antlr.antlr
version: 2.7.7
indirect: true
- name: com.apple.AppleJavaExtensions
version: "1.4"
indirect: true
- name: com.beust.jcommander
version: "1.48"
indirect: true
- name: com.google.code.findbugs.bcel-findbugs
version: "6.0"
indirect: true
- name: com.google.code.findbugs.findbugs
version: 3.0.1
- name: com.google.code.findbugs.jFormatString
version: 2.0.1
indirect: true
- name: com.google.code.findbugs.jsr305
version: 1.3.9
indirect: true
- name: com.google.code.findbugs.jsr305
version: 2.0.1
indirect: true
- name: com.google.code.gson.gson
version: "2.5"
indirect: true
- name: com.google.errorprone.error_prone_annotations
version: 2.0.18
indirect: true
- name: com.google.guava.guava
version: "23.0"
- name: com.google.guava.guava
version: 23.2-jre
indirect: true
- name: com.google.j2objc.j2objc-annotations
version: "1.1"
indirect: true
- name: com.puppycrawl.tools.checkstyle
version: "8.4"
- name: commons-beanutils.commons-beanutils
version: 1.9.3
indirect: true
- name: commons-cli.commons-cli
version: "1.4"
indirect: true
- name: commons-collections.commons-collections
version: 3.2.2
indirect: true
- name: commons-io.commons-io
version: "2.4"
indirect: true
- name: commons-lang.commons-lang
version: "2.6"
indirect: true
- name: dom4j.dom4j
version: 1.6.1
indirect: true
- name: jaxen.jaxen
version: 1.1.6
indirect: true
- name: junit.junit
version: "4.12"
- name: net.bytebuddy.byte-buddy
version: 1.7.4
indirect: true
- name: net.bytebuddy.byte-buddy-agent
version: 1.7.4
indirect: true
- name: net.java.dev.javacc.javacc
version: "5.0"
indirect: true
- name: net.jcip.jcip-annotations
version: "1.0"
indirect: true
- name: net.sf.saxon.Saxon-HE
version: 9.8.0-5
indirect: true
- name: net.sourceforge.pmd.pmd-core
version: 5.6.1
indirect: true
- name: net.sourceforge.pmd.pmd-java
version: 5.6.1
- name: net.sourceforge.saxon.saxon
version: 9.1.0.8
indirect: true
- name: org.antlr.antlr4-runtime
version: "4.7"
indirect: true
- name: org.apache.commons.commons-lang3
version: "3.4"
indirect: true
- name: org.apache.logging.log4j.log4j-api
version: 2.9.1
- name: org.apache.logging.log4j.log4j-core
version: 2.9.1
- name: org.apache.logging.log4j.log4j-slf4j-impl
version: 2.9.1
- name: org.codehaus.mojo.animal-sniffer-annotations
version: "1.14"
indirect: true
- name: org.hamcrest.hamcrest-core
version: "1.3"
indirect: true
- name: org.mockito.mockito-core
version: 2.11.0
- name: org.objenesis.objenesis
version: "2.6"
indirect: true
- name: org.ow2.asm.asm
version: 5.0.2
indirect: true
- name: org.ow2.asm.asm
version: 5.0.4
indirect: true
- name: org.ow2.asm.asm-commons
version: 5.0.2
indirect: true
- name: org.ow2.asm.asm-debug-all
version: 5.0.2
indirect: true
- name: org.ow2.asm.asm-tree
version: 5.0.2
indirect: true
- name: org.slf4j.slf4j-api
version: 1.7.25
indirect: true
- name: xml-apis.xml-apis
version: 1.0.b2
indirect: true
- fileURI: file:///analyzer-lsp/examples/inclusion-tests/pom.xml
provider: java
dependencies: []
Expand Down
31 changes: 31 additions & 0 deletions demo-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,30 @@
variables:
name: sigs.k8s.io/structured-merge-diff/v4
version: v4.2.1
java-gradle-project:
description: |
This rule looks for a class only present in the gradle project
category: mandatory
incidents:
- uri: file:///examples/gradle-multi-project-example/template-server/src/main/java/io/jeffchao/template/server/Server.java
message: Only incidents in gradle project should appear
codeSnip: " 1 package io.jeffchao.template.server;\n 2 \n 3 import java.io.IOException;\n 4 import java.io.OutputStream;\n 5 import java.net.InetSocketAddress;\n 6 \n 7 import com.sun.net.httpserver.HttpExchange;\n 8 import com.sun.net.httpserver.HttpHandler;\n 9 import com.sun.net.httpserver.HttpServer;\n10 \n11 public class Server {\n12 \n13 public static void main(String[] args) throws IOException {\n14 String portString = System.getenv(\"PORT\");\n15 int port = portString == null ? 8080 : Integer.valueOf(portString);\n16 HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);\n17 server.createContext(\"/\", new MyHandler());"
lineNumber: 7
variables:
file: file:///examples/gradle-multi-project-example/template-server/src/main/java/io/jeffchao/template/server/Server.java
kind: Module
name: com.sun.net.httpserver.HttpExchange
package: io.jeffchao.template.server
- uri: file:///examples/gradle-multi-project-example/template-server/src/main/java/io/jeffchao/template/server/Server.java
message: Only incidents in gradle project should appear
codeSnip: "14 String portString = System.getenv(\"PORT\");\n15 int port = portString == null ? 8080 : Integer.valueOf(portString);\n16 HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);\n17 server.createContext(\"/\", new MyHandler());\n18 server.setExecutor(null); // creates a default executor\n19 server.start();\n20 }\n21 \n22 static class MyHandler implements HttpHandler {\n23 @Override\n24 public void handle(HttpExchange t) throws IOException {\n25 String response = \"Hello from Gradle!\";\n26 t.sendResponseHeaders(200, response.length());\n27 OutputStream os = t.getResponseBody();\n28 os.write(response.getBytes());\n29 os.close();\n30 }\n31 }\n32 }\n"
lineNumber: 24
variables:
file: file:///examples/gradle-multi-project-example/template-server/src/main/java/io/jeffchao/template/server/Server.java
kind: Method
name: handle
package: io.jeffchao.template.server
effort: 3
java-inclusion-test:
description: "This rule tests includedPaths config of the java provider. There should be two instances of this issue in the example app. \nWe are filtering one of them using includedPaths in provider config.\n"
category: mandatory
Expand Down Expand Up @@ -381,6 +405,13 @@
description: ""
category: potential
incidents:
- uri: file:///examples/gradle-multi-project-example/build.gradle
message: dependency junit.junit with 4.12 is bad and you should feel bad for using it
codeSnip: " 1 apply plugin: 'idea'\n 2 \n 3 ext {\n 4 log4jVersion = '2.9.1'\n 5 }\n 6 \n 7 buildscript {\n 8 repositories {\n 9 jcenter()\n10 }\n11 dependencies {"
lineNumber: 0
variables:
name: junit.junit
version: "4.12"
- uri: file:///examples/java/pom.xml
message: dependency io.fabric8.kubernetes-client with 6.0.0 is bad and you should feel bad for using it
codeSnip: "26 \n27 <dependencies>\n28 <dependency>\n29 <groupId>junit</groupId>\n30 <artifactId>junit</artifactId>\n31 <version>4.11</version>\n32 <scope>test</scope>\n33 </dependency>\n34 <dependency>\n35 <groupId>io.fabric8</groupId>\n36 <artifactId>kubernetes-client</artifactId>\n37 <version>6.0.0</version>\n38 </dependency>\n39 <dependency>\n40 <groupId>io.fabric8</groupId>\n41 <artifactId>kubernetes-client-api</artifactId>\n42 <version>6.0.0</version>\n43 </dependency>\n44 <dependency>\n45 <groupId>javax</groupId>\n46 <artifactId>javaee-api</artifactId>"
Expand Down
1 change: 1 addition & 0 deletions examples/golang/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD
github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/getkin/kin-openapi v0.76.0/go.mod h1:660oXbgy5JFMKreazJaQTw7o+X00qeSyhcnluiMv+Xg=
github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
Expand Down
2 changes: 1 addition & 1 deletion external-providers/java-external-provider/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ COPY --from=builder /java-provider/java-external-provider /usr/local/bin/java-ex

EXPOSE 14651

ENTRYPOINT ["java-external-provider", "--port", "14651"]
ENTRYPOINT ["java-external-provider", "--port", "14651"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
### Intellij+iml ###
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### Intellij+iml Patch ###
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023

.idea/

*.iml
modules.xml
.idea/misc.xml
*.ipr

### Java ###
# Compiled class file
*.class

# Log file
*.log

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Gradle ###
.gradle
**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Cache of project
.gradletasknamecache
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [author]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
web: java -jar build/libs/template-server-all.jar
worker: java -jar build/libs/template-core-all.jar
Loading
Loading