diff --git a/.github/scripts/sign-osx-distro-file.sh b/.github/scripts/sign-osx-distro-file.sh index f8c2cd7c54..57d77ac9e8 100755 --- a/.github/scripts/sign-osx-distro-file.sh +++ b/.github/scripts/sign-osx-distro-file.sh @@ -73,21 +73,12 @@ function signExecutableInsideNestedJar() { cd $pwd } -# sign libjansi.jnilib inside kotlin-compiler-embeddable.jar -signExecutableInsideJar ${dir}/${destination_folder_name}/SpringToolsForEclipse.app ".*/kotlin-compiler-embeddable.*\.jar$" "libjansi.jnilib" ".*/libjansi\.jnilib$" - -# sign libsnappyjava.jnilib and libsnappyjava.dylib inside snappy-java.jar -signExecutableInsideJar ${dir}/${destination_folder_name}/SpringToolsForEclipse.app ".*/snappy-java.*\.jar$" "libsnappyjava.jnilib" ".*/libsnappyjava\.(jni|dy)lib$" - # sign libjnidispatch.jnilib inside jna.jar signExecutableInsideJar ${dir}/${destination_folder_name}/SpringToolsForEclipse.app ".*/jna-\d+.*\.jar$" "libjnidispatch.jnilib.jnilib" ".*/libjnidispatch\.jnilib$" #sign libjnidispatch.jnilib inside jna.jar which is inside org.springframework.ide.eclipse.docker.client.jar bundle signExecutableInsideNestedJar ${dir}/${destination_folder_name}/SpringToolsForEclipse.app ".*/org.springframework.ide.eclipse.docker.client.*\.jar$" ".*/jna-\d+.*\.jar$" "libjnidispatch.jnilib" ".*/libjnidispatch\.jnilib$" -#sign libjnidispatch.jnilib inside develocity-gradle-plugin.jar which is inside rewrite-gradle.jar bundle -#signExecutableInsideNestedJar ${dir}/${destination_folder_name}/SpringToolsForEclipse.app ".*/rewrite-gradle-\d+.*\.jar$" ".*/develocity-gradle-plugin.*\.jar$" "libjnidispatch.jnilib" ".*/libjnidispatch\.jnilib$" - # Sign the app ls -la ${dir}/${destination_folder_name}/SpringToolsForEclipse.app/ codesign --verbose --deep --force --timestamp --entitlements "${entitlements}" --options=runtime --keychain "${KEYCHAIN}" -s "${MACOS_CERTIFICATE_ID}" ${dir}/${destination_folder_name}/SpringToolsForEclipse.app diff --git a/headless-services/commons/commons-rewrite/pom.xml b/headless-services/commons/commons-rewrite/pom.xml index 4493e37ae9..847cdad076 100644 --- a/headless-services/commons/commons-rewrite/pom.xml +++ b/headless-services/commons/commons-rewrite/pom.xml @@ -36,14 +36,6 @@ org.openrewrite rewrite-maven - - org.openrewrite - rewrite-groovy - - - org.openrewrite - rewrite-gradle - org.openrewrite rewrite-yaml @@ -72,15 +64,6 @@ rewrite-java-25 runtime - - org.openrewrite.gradle.tooling - model - - - org.gradle - gradle-tooling-api - runtime - org.eclipse.jgit org.eclipse.jgit diff --git a/headless-services/commons/commons-rewrite/src/main/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParser.java b/headless-services/commons/commons-rewrite/src/main/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParser.java deleted file mode 100644 index 2650166b3a..0000000000 --- a/headless-services/commons/commons-rewrite/src/main/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParser.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 VMware, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VMware, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.rewrite.gradle; - -import static org.openrewrite.Tree.randomId; - -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.openrewrite.ExecutionContext; -import org.openrewrite.Parser.Input; -import org.openrewrite.SourceFile; -import org.openrewrite.gradle.GradleParser; -import org.openrewrite.gradle.marker.GradleProject; -import org.openrewrite.gradle.toolingapi.OpenRewriteModel; -import org.openrewrite.gradle.toolingapi.OpenRewriteModelBuilder; -import org.openrewrite.groovy.GroovyParser; -import org.openrewrite.groovy.tree.G; -import org.openrewrite.internal.ListUtils; -import org.openrewrite.java.JavaParser.Builder; -import org.openrewrite.java.marker.JavaProject; -import org.openrewrite.java.marker.JavaVersion; -import org.openrewrite.marker.BuildTool; -import org.openrewrite.marker.Marker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.rewrite.java.AbstractJavaProjectParser; - -public class GradleIJavaProjectParser extends AbstractJavaProjectParser { - - private static final Logger log = LoggerFactory.getLogger(GradleIJavaProjectParser.class); - - public GradleIJavaProjectParser(IJavaProject jp, Builder javaParserBuilder, - Function parserInputProvider) { - super(jp, javaParserBuilder, parserInputProvider); - } - - @Override - protected List getJavaProvenance(SourceFile buildFileAst, Path projectDirectory) { - Optional gradleProject = buildFileAst.getMarkers().findFirst(GradleProject.class); - - String javaRuntimeVersion = System.getProperty("java.runtime.version"); - String javaVendor = System.getProperty("java.vm.vendor"); - String sourceCompatibility = javaRuntimeVersion; - String targetCompatibility = javaRuntimeVersion; - - return Arrays.asList( - new BuildTool(randomId(), BuildTool.Type.Gradle, null), - new JavaVersion(randomId(), javaRuntimeVersion, javaVendor, sourceCompatibility, targetCompatibility), - new JavaProject(randomId(), gradleProject.map(g -> g.getName()).orElse(null), null/*new JavaProject.Publication( - mavenModel.getGroupId(), - mavenModel.getArtifactId(), - mavenModel.getVersion()*/ - ) - ); - } - - @Override - public List parseBuildFiles(Path projectDir, ExecutionContext ctx) { - try { - OpenRewriteModel openRewriteGradleModel = OpenRewriteModelBuilder.forProjectDirectory(projectDir.toFile(), Paths.get(jp.getProjectBuild().getBuildFile()).toFile()); - GradleProject gradleProject =openRewriteGradleModel.getGradleProject(); - GradleParser gradleParser = GradleParser.builder().groovyParser(GroovyParser.builder()).build(); - - Path buildFilePath = Paths.get(jp.getProjectBuild().getBuildFile()); - - List gradleFiles = gradleParser.parseInputs(() -> - getInputs(Stream.of(buildFilePath)).iterator(), null, ctx).map(G.CompilationUnit.class::cast).collect(Collectors.toList()); - return ListUtils.map( - gradleFiles, (i, gb) -> gb.withMarkers(gb.getMarkers().addIfAbsent(gradleProject)) - ); - } catch (IOException e) { - log.error("", e); - return List.of(); - } - } - -} diff --git a/headless-services/commons/commons-rewrite/src/test/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParserTest.java b/headless-services/commons/commons-rewrite/src/test/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParserTest.java deleted file mode 100644 index dd3c602194..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/java/org/springframework/ide/vscode/commons/rewrite/gradle/GradleIJavaProjectParserTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 VMware, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VMware, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.commons.rewrite.gradle; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; -import org.openrewrite.InMemoryExecutionContext; -import org.openrewrite.SourceFile; -import org.openrewrite.java.JavaParser; -import org.openrewrite.java.marker.JavaSourceSet; -import org.openrewrite.java.tree.J; -import org.openrewrite.java.tree.JavaSourceFile; -import org.openrewrite.properties.tree.Properties; -import org.openrewrite.text.PlainText; -import org.openrewrite.yaml.tree.Yaml; -import org.springframework.ide.vscode.commons.gradle.GradleCore; -import org.springframework.ide.vscode.commons.gradle.GradleJavaProject; -import org.springframework.ide.vscode.commons.java.IJavaProject; -import org.springframework.ide.vscode.commons.rewrite.java.ProjectParser; - -public class GradleIJavaProjectParserTest { - - @Disabled - @Test - void testSingleGroovy() throws Exception { - URL resource = getClass().getResource("/test-projects/example-gradle-groovy"); - Path testProjectPath = Paths.get(resource.toURI()); - - IJavaProject jp = GradleJavaProject.create(null, GradleCore.getDefault(), testProjectPath.resolve("build.gradle").toFile(), null); - - GradleIJavaProjectParser parser = new GradleIJavaProjectParser(jp, JavaParser.fromJavaVersion(), null); - - List sources = parser.parse(Paths.get(jp.getLocationUri()), new InMemoryExecutionContext(t -> { - throw new RuntimeException(t); - })); - - assertEquals(9, sources.size()); - - // java sources - assertEquals(2, sources.stream().filter(J.CompilationUnit.class::isInstance).collect(Collectors.toList()).size()); - - // java sources from main - assertEquals(1, sources.stream().filter(JavaSourceFile.class::isInstance).map(JavaSourceFile.class::cast).filter(j -> { - String sourceSetName = j.getMarkers().findFirst(JavaSourceSet.class).map(js -> js.getName()).orElse(null); - return ProjectParser.MAIN.equals(sourceSetName); - }).collect(Collectors.toList()).size()); - - // java sources from test - assertEquals(1, sources.stream().filter(JavaSourceFile.class::isInstance).map(JavaSourceFile.class::cast).filter(j -> { - String sourceSetName = j.getMarkers().findFirst(JavaSourceSet.class).map(js -> js.getName()).orElse(null); - return ProjectParser.TEST.equals(sourceSetName); - }).collect(Collectors.toList()).size()); - - // properties files - assertEquals(1, sources.stream().filter(Properties.File.class::isInstance).collect(Collectors.toList()).size()); - - // application properties - assertEquals(1, sources.stream().filter(Properties.File.class::isInstance).filter(f -> f.getSourcePath().getFileName().toString().equals("application.properties")).collect(Collectors.toList()).size()); - - // yaml files - assertEquals(2, sources.stream().filter(Yaml.Documents.class::isInstance).collect(Collectors.toList()).size()); - - // application yaml - assertEquals(2, sources.stream().filter(Yaml.Documents.class::isInstance).filter(f -> f.getSourcePath().getFileName().toString().equals("application.yml")).collect(Collectors.toList()).size()); - - // plain text files - assertEquals(3, sources.stream().filter(PlainText.class::isInstance).collect(Collectors.toList()).size()); - - // .factories files - assertEquals(3, sources.stream().filter(PlainText.class::isInstance).filter(f -> f.getSourcePath().getFileName().toString().endsWith(".factories")).collect(Collectors.toList()).size()); - - - } - -} diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/.gitignore b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/.gitignore deleted file mode 100644 index c2065bc262..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -HELP.md -.gradle -build/ -!gradle/wrapper/gradle-wrapper.jar -!**/src/main/**/build/ -!**/src/test/**/build/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache -bin/ -!**/src/main/**/bin/ -!**/src/test/**/bin/ - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr -out/ -!**/src/main/**/out/ -!**/src/test/**/out/ - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ - -### VS Code ### -.vscode/ diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/build.gradle b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/build.gradle deleted file mode 100644 index d1344e8371..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - id 'java' - id 'org.springframework.boot' version '3.0.7' - id 'io.spring.dependency-management' version '1.1.0' -} - -group = 'com.example' -version = '0.0.1-SNAPSHOT' -sourceCompatibility = '17' - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-starter-web' - testImplementation 'org.springframework.boot:spring-boot-starter-test' -} - -tasks.named('test') { - useJUnitPlatform() -} diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.jar b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index d64cd49177..0000000000 Binary files a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.properties b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 1af9e0930b..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew deleted file mode 100755 index 1aa94a4269..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew.bat b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew.bat deleted file mode 100644 index 6689b85bee..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/settings.gradle b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/settings.gradle deleted file mode 100644 index 094e8e5786..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'example-gradle-groovy' diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/java/com/example/demo/ExampleGradleGroovyApplication.java b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/java/com/example/demo/ExampleGradleGroovyApplication.java deleted file mode 100644 index 50d1d663ee..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/java/com/example/demo/ExampleGradleGroovyApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ExampleGradleGroovyApplication { - - public static void main(String[] args) { - SpringApplication.run(ExampleGradleGroovyApplication.class, args); - } - -} diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.properties b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.properties deleted file mode 100644 index 73b813d277..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.properties +++ /dev/null @@ -1,4 +0,0 @@ -test-map.test-list-object.string-list[0]=not-a-color -test-map.test-list-object.string-list[1]=RED -test-map.test-list-object.string-list[2]=GREEN -test-map.some-key.list[0]=something diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.yml b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.yml deleted file mode 100644 index 5697ab735c..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 6574 \ No newline at end of file diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/more.factories b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/more.factories deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/spring.factories b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/main/resources/spring.factories deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/java/com/example/demo/ExampleGradleGroovyApplicationTests.java b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/java/com/example/demo/ExampleGradleGroovyApplicationTests.java deleted file mode 100644 index ca0135b8cc..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/java/com/example/demo/ExampleGradleGroovyApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ExampleGradleGroovyApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/resources/application.yml b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/resources/application.yml deleted file mode 100644 index 57d0099303..0000000000 --- a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/resources/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 3243 \ No newline at end of file diff --git a/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/resources/spring.factories b/headless-services/commons/commons-rewrite/src/test/resources/test-projects/example-gradle-groovy/src/test/resources/spring.factories deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/RewriteRecipeRepository.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/RewriteRecipeRepository.java index c55fc39818..072fede989 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/RewriteRecipeRepository.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/RewriteRecipeRepository.java @@ -51,7 +51,6 @@ import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; import org.springframework.ide.vscode.commons.protocol.java.ProjectBuild; import org.springframework.ide.vscode.commons.rewrite.ORDocUtils; -import org.springframework.ide.vscode.commons.rewrite.gradle.GradleIJavaProjectParser; import org.springframework.ide.vscode.commons.rewrite.java.ProjectParser; import org.springframework.ide.vscode.commons.rewrite.maven.MavenIJavaProjectParser; import org.springframework.ide.vscode.commons.util.text.TextDocument; @@ -239,8 +238,6 @@ private static ProjectParser createRewriteProjectParser(IJavaProject jp, Functio case ProjectBuild.MAVEN_PROJECT_TYPE: MavenParser.Builder mavenParserBuilder = MavenParser.builder(); return new MavenIJavaProjectParser(jp, JavaParser.fromJavaVersion(), inputProvider, mavenParserBuilder); - case ProjectBuild.GRADLE_PROJECT_TYPE: - return new GradleIJavaProjectParser(jp, JavaParser.fromJavaVersion(), inputProvider); default: throw new IllegalStateException("The project is neither Maven nor Gradle!"); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/SpringBootUpgrade.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/SpringBootUpgrade.java index 6cd3faa214..5ddb43d355 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/SpringBootUpgrade.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/java/rewrite/SpringBootUpgrade.java @@ -17,13 +17,13 @@ import org.eclipse.lsp4j.TextDocumentIdentifier; import org.openrewrite.Recipe; import org.openrewrite.config.DeclarativeRecipe; -import org.openrewrite.gradle.plugins.UpgradePluginVersion; import org.openrewrite.maven.UpgradeParentVersion; import org.springframework.ide.vscode.commons.Version; import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.java.SpringProjectUtil; import org.springframework.ide.vscode.commons.languageserver.java.JavaProjectFinder; import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer; +import org.springframework.ide.vscode.commons.protocol.java.ProjectBuild; import org.springframework.ide.vscode.commons.util.Assert; import com.google.gson.JsonElement; @@ -43,6 +43,8 @@ public SpringBootUpgrade(SimpleLanguageServer server, RewriteRecipeRepository re IJavaProject project = projectFinder.find(new TextDocumentIdentifier(uri)).orElse(null); Assert.isLegal(project != null, "No Spring Boot project found for uri: " + uri); + Assert.isLegal(ProjectBuild.MAVEN_PROJECT_TYPE.equals(project.getProjectBuild().getType()), "Only Maven projects supported"); + Version version = SpringProjectUtil.getDependencyVersion(project, SpringProjectUtil.SPRING_BOOT); // Version upgrade is not supposed to work for patch version. Only for the major and minor versions. @@ -69,8 +71,6 @@ private Recipe createUpgradeRecipe(Version version, Version targetVersion) { // patch version upgrade - treat as pom versions only upgrade recipe.getRecipeList().add(new org.openrewrite.maven.UpgradeDependencyVersion("org.springframework.boot", "*", version.getMajor() + "." + version.getMinor() + ".x", null, null, null)); recipe.getRecipeList().add(new UpgradeParentVersion("org.springframework.boot", "spring-boot-starter-parent", version.getMajor() + "." + version.getMinor() + ".x", null, null)); - recipe.getRecipeList().add(new org.openrewrite.gradle.UpgradeDependencyVersion("org.springframework.boot", "*", version.getMajor() + "." + version.getMinor() + ".x", null)); - recipe.getRecipeList().add(new UpgradePluginVersion("org.springframework.boot", version.getMajor() + "." + version.getMinor() + ".x", null)); } if (recipe.getRecipeList().isEmpty()) { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/UpdateBootVersion.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/UpdateBootVersion.java index c3d1050d16..fce33b9bb0 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/UpdateBootVersion.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/validation/generations/UpdateBootVersion.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2023, 2024 VMware, Inc. + * Copyright (c) 2023, 2025 VMware, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -28,6 +28,7 @@ import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.java.SpringProjectUtil; import org.springframework.ide.vscode.commons.languageserver.reconcile.DiagnosticSeverityProvider; +import org.springframework.ide.vscode.commons.protocol.java.ProjectBuild; import com.google.common.collect.ImmutableList; @@ -55,6 +56,10 @@ public Collection validate(IJavaProject javaProject, Version javaPro return builder.build(); } + private boolean canProvideQuickfix(IJavaProject jp) { + return ProjectBuild.MAVEN_PROJECT_TYPE.equals(jp.getProjectBuild().getType()); + } + private Optional validateMajorVersion(IJavaProject javaProject, Version javaProjectVersion, List sortedBootVersions) { Version latest = VersionValidationUtils.getNewerLatestMajorRelease(sortedBootVersions, javaProjectVersion); @@ -67,19 +72,21 @@ private Optional validateMajorVersion(IJavaProject javaProject, Vers List actions = new ArrayList<>(2); - bootUpgradeOpt.flatMap(bu -> bu.getNearestAvailableMinorVersion(latest)).map(targetVersion -> { - Version upgradeVersion = Version.parse(targetVersion); - if (javaProjectVersion.compareTo(upgradeVersion) >= 0) { - return null; - } - CodeAction c = new CodeAction(); - c.setKind(CodeActionKind.QuickFix); - c.setTitle("Upgrade to Spring Boot " + targetVersion + " (executes the full project conversion recipe from OpenRewrite)"); - String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; - c.setCommand(new Command("Upgrade to Version " + targetVersion, commandId, - ImmutableList.of(javaProject.getLocationUri().toASCIIString(), targetVersion, true))); - return c; - }).ifPresent(actions::add); + if (canProvideQuickfix(javaProject)) { + bootUpgradeOpt.flatMap(bu -> bu.getNearestAvailableMinorVersion(latest)).map(targetVersion -> { + Version upgradeVersion = Version.parse(targetVersion); + if (javaProjectVersion.compareTo(upgradeVersion) >= 0) { + return null; + } + CodeAction c = new CodeAction(); + c.setKind(CodeActionKind.QuickFix); + c.setTitle("Upgrade to Spring Boot " + targetVersion + " (executes the full project conversion recipe from OpenRewrite)"); + String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; + c.setCommand(new Command("Upgrade to Version " + targetVersion, commandId, + ImmutableList.of(javaProject.getLocationUri().toASCIIString(), targetVersion, true))); + return c; + }).ifPresent(actions::add); + } actions.add(openReleaseNotesCodeAction(latest)); @@ -100,19 +107,21 @@ private Optional validateMinorVersion(IJavaProject javaProject, Vers List actions = new ArrayList<>(2); - bootUpgradeOpt.flatMap(bu -> bu.getNearestAvailableMinorVersion(latest)).map(targetVersion -> { - Version upgradeVersion = Version.parse(targetVersion); - if (javaProjectVersion.compareTo(upgradeVersion) >= 0) { - return null; - } - CodeAction c = new CodeAction(); - c.setKind(CodeActionKind.QuickFix); - c.setTitle("Upgrade to Spring Boot " + targetVersion + " (executes the full project conversion recipe from OpenRewrite)"); - String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; - c.setCommand(new Command("Upgrade to Version " + targetVersion, commandId, - ImmutableList.of(javaProject.getLocationUri().toASCIIString(), targetVersion, true))); - return c; - }).ifPresent(actions::add); + if (canProvideQuickfix(javaProject)) { + bootUpgradeOpt.flatMap(bu -> bu.getNearestAvailableMinorVersion(latest)).map(targetVersion -> { + Version upgradeVersion = Version.parse(targetVersion); + if (javaProjectVersion.compareTo(upgradeVersion) >= 0) { + return null; + } + CodeAction c = new CodeAction(); + c.setKind(CodeActionKind.QuickFix); + c.setTitle("Upgrade to Spring Boot " + targetVersion + " (executes the full project conversion recipe from OpenRewrite)"); + String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; + c.setCommand(new Command("Upgrade to Version " + targetVersion, commandId, + ImmutableList.of(javaProject.getLocationUri().toASCIIString(), targetVersion, true))); + return c; + }).ifPresent(actions::add); + } actions.add(openReleaseNotesCodeAction(latest)); @@ -133,15 +142,17 @@ private Optional validatePatchVersion(IJavaProject javaProject, Vers List actions = new ArrayList<>(2); - bootUpgradeOpt.map(bu -> { - CodeAction c = new CodeAction(); - c.setKind(CodeActionKind.QuickFix); - c.setTitle("Upgrade to Spring Boot " + latest.toString() + " (Maven dependency version changes only)"); - String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; - c.setCommand(new Command("Upgrade to Version " + latest.toString(), commandId, - ImmutableList.of(javaProject.getLocationUri().toASCIIString(), latest.toString(), false))); - return c; - }).ifPresent(actions::add); + if (canProvideQuickfix(javaProject)) { + bootUpgradeOpt.map(bu -> { + CodeAction c = new CodeAction(); + c.setKind(CodeActionKind.QuickFix); + c.setTitle("Upgrade to Spring Boot " + latest.toString() + " (Maven dependency version changes only)"); + String commandId = SpringBootUpgrade.CMD_UPGRADE_SPRING_BOOT; + c.setCommand(new Command("Upgrade to Version " + latest.toString(), commandId, + ImmutableList.of(javaProject.getLocationUri().toASCIIString(), latest.toString(), false))); + return c; + }).ifPresent(actions::add); + } actions.add(openReleaseNotesCodeAction(latest));