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 #93

Merged
merged 4 commits into from
May 20, 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
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ RUN microdnf install -y go-toolset && microdnf clean all && rm -rf /var/cache/dn
RUN go install golang.org/x/tools/gopls@latest

FROM registry.access.redhat.com/ubi9/ubi-minimal
RUN microdnf install -y python39 java-17-openjdk-devel golang-bin tar gzip --nodocs --setopt=install_weak_deps=0 && microdnf clean all && rm -rf /var/cache/dnf
# Java 1.8 is required for backwards compatibility with older versions of Gradle
RUN microdnf install -y python39 java-1.8.0-openjdk-devel java-17-openjdk-devel golang-bin tar gzip zip --nodocs --setopt=install_weak_deps=0 && microdnf clean all && rm -rf /var/cache/dnf
jmle marked this conversation as resolved.
Show resolved Hide resolved
ENV JAVA_HOME /usr/lib/jvm/java-17-openjdk
# Specify Java 1.8 home for usage with gradle wrappers
ENV JAVA8_HOME /usr/lib/jvm/java-1.8.0-openjdk
RUN curl -fsSL -o /tmp/apache-maven.tar.gz https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-bin.tar.gz && \
tar -xzf /tmp/apache-maven.tar.gz -C /usr/local/ && \
ln -s /usr/local/apache-maven-3.9.5/bin/mvn /usr/bin/mvn && \
rm /tmp/apache-maven.tar.gz
ENV M2_HOME /usr/local/apache-maven-3.9.5

# TODO(jmle): remove this when plugin is fixed - installs fixed dependency plugin to fetch sources
COPY ./hack/3.6.2-SNAPSHOT /root/.m2/repository/org/apache/maven/plugins/maven-dependency-plugin/3.6.2-SNAPSHOT
# Copy "download sources" gradle task. This is needed to download project sources.
RUN mkdir /root/.gradle
COPY ./gradle/build.gradle /root/.gradle/task.gradle

COPY --from=gopls-build /root/go/bin/gopls /root/go/bin/gopls
COPY --from=jdtls-download /jdtls /jdtls/
Expand Down
35 changes: 35 additions & 0 deletions gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Sources download task for Gradle, tested in versions 4+
*/
task konveyorDownloadSources {
allprojects { project ->
project.getConfigurations().each { config ->
config.setCanBeResolved(true)

inputs.files config
outputs.dir "${buildDir}/download"
doLast {
def componentIds = config.incoming.resolutionResult.allDependencies.collect { it.selected.id }
ArtifactResolutionResult result = dependencies.createArtifactResolutionQuery()
.forComponents(componentIds)
.withArtifacts(JvmLibrary, SourcesArtifact)
.execute()
def sourceArtifacts = []
result.resolvedComponents.each { ComponentArtifactsResult component ->
Set<ArtifactResult> sources = component.getArtifacts(SourcesArtifact)
println "Found ${sources.size()} sources for ${component.id}"
sources.each { ArtifactResult ar ->
if (ar instanceof ResolvedArtifactResult) {
sourceArtifacts << ar.file
}
}
}

copy {
from sourceArtifacts
into "${buildDir}/download"
}
}
}
}
}
4 changes: 0 additions & 4 deletions hack/3.6.2-SNAPSHOT/_remote.repositories

This file was deleted.

Binary file not shown.
Loading
Loading