From 1a60ddb54532e30bf4ba6f3970eca1b6d61e4944 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 26 Jun 2020 16:46:08 -0400 Subject: [PATCH] Send project name to the client along with labels. This is useful when presenting the different projects in a menu, such as in https://github.com/redhat-developer/vscode-quarkus/issues/215. Signed-off-by: David Thompson --- .../commons/ProjectLabelInfoEntry.java | 15 +- .../jdt/core/ProjectLabelManager.java | 2 +- .../gradle/renamed-gradle/.dockerignore | 4 + .../projects/gradle/renamed-gradle/.project | 17 ++ .../projects/gradle/renamed-gradle/README.md | 35 ++++ .../gradle/renamed-gradle/build.gradle | 39 ++++ .../gradle/renamed-gradle/gradle.properties | 6 + .../gradle/wrapper/gradle-wrapper.properties | 5 + .../projects/gradle/renamed-gradle/gradlew | 183 ++++++++++++++++++ .../gradle/renamed-gradle/gradlew.bat | 103 ++++++++++ .../gradle/renamed-gradle/settings.gradle | 11 ++ .../src/main/docker/Dockerfile.jvm | 54 ++++++ .../src/main/docker/Dockerfile.native | 24 +++ .../java/org/renamed/GreetingResource.java | 16 ++ .../resources/META-INF/resources/index.html | 155 +++++++++++++++ .../src/main/resources/application.properties | 2 + .../org/renamed/NativeGreetingResourceIT.java | 9 + .../org/renamed/GreetingResourceTest.java | 21 ++ .../jdt/core/BasePropertiesManagerTest.java | 5 +- .../jdt/core/ProjectLabelTest.java | 41 +++- 20 files changed, 738 insertions(+), 9 deletions(-) create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.dockerignore create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.project create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/README.md create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/build.gradle create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle.properties create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle/wrapper/gradle-wrapper.properties create mode 100755 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew create mode 100755 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew.bat create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/settings.gradle create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.jvm create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.native create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/java/org/renamed/GreetingResource.java create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/META-INF/resources/index.html create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/application.properties create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/native-test/java/org/renamed/NativeGreetingResourceIT.java create mode 100644 microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/test/java/org/renamed/GreetingResourceTest.java diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/commons/ProjectLabelInfoEntry.java b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/commons/ProjectLabelInfoEntry.java index 933165d59..15b6a8370 100644 --- a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/commons/ProjectLabelInfoEntry.java +++ b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/commons/ProjectLabelInfoEntry.java @@ -21,14 +21,16 @@ * */ public class ProjectLabelInfoEntry { - public static final ProjectLabelInfoEntry EMPTY_PROJECT_INFO = new ProjectLabelInfoEntry("", + public static final ProjectLabelInfoEntry EMPTY_PROJECT_INFO = new ProjectLabelInfoEntry("", "", Collections.emptyList()); private final String uri; + private final String name; private final List labels; - public ProjectLabelInfoEntry(String uri, List labels) { + public ProjectLabelInfoEntry(String uri, String name, List labels) { this.uri = uri; + this.name = name; this.labels = labels; } @@ -41,6 +43,15 @@ public String getUri() { return uri; } + /** + * Returns the name of the project + * + * @return The name of this project + */ + public String getName() { + return name; + } + /** * Returns the labels for the current project uri * diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelManager.java b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelManager.java index 065b2b086..380aa7887 100644 --- a/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelManager.java +++ b/microprofile.jdt/com.redhat.microprofile.jdt.core/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelManager.java @@ -73,7 +73,7 @@ public List getProjectLabelInfo() { private ProjectLabelInfoEntry getProjectLabelInfo(IProject project, List types) { String uri = JDTMicroProfileUtils.getProjectURI(project); if (uri != null) { - return new ProjectLabelInfoEntry(uri, getProjectLabels(project, types)); + return new ProjectLabelInfoEntry(uri, project.getName(), getProjectLabels(project, types)); } return null; } diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.dockerignore b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.dockerignore new file mode 100644 index 000000000..482f01301 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.dockerignore @@ -0,0 +1,4 @@ +* +!build/*-runner +!build/*-runner.jar +!build/lib/* \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.project b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.project new file mode 100644 index 000000000..40c511fff --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/.project @@ -0,0 +1,17 @@ + + + renamed-gradle + Project renamed-gradle created by Buildship. + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + org.eclipse.buildship.core.gradleprojectnature + + diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/README.md b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/README.md new file mode 100644 index 000000000..aa571b692 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/README.md @@ -0,0 +1,35 @@ +# renamed-gradle project + +This project uses Quarkus, the Supersonic Subatomic Java Framework. + +If you want to learn more about Quarkus, please visit its website: https://quarkus.io/ . + +## Running the application in dev mode + +You can run your application in dev mode that enables live coding using: +``` +./gradlew quarkusDev +``` + +## Packaging and running the application + +The application can be packaged using `./gradlew quarkusBuild`. +It produces the `renamed-gradle-1.0.0-SNAPSHOT-runner.jar` file in the `build` directory. +Be aware that it’s not an _über-jar_ as the dependencies are copied into the `build/lib` directory. + +The application is now runnable using `java -jar build/renamed-gradle-1.0.0-SNAPSHOT-runner.jar`. + +If you want to build an _über-jar_, just add the `--uber-jar` option to the command line: +``` +./gradlew quarkusBuild --uber-jar +``` + +## Creating a native executable + +You can create a native executable using: `./gradlew build -Dquarkus.package.type=native`. + +Or, if you don't have GraalVM installed, you can run the native executable build in a container using: `./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true`. + +You can then execute your native executable with: `./build/renamed-gradle-1.0.0-SNAPSHOT-runner` + +If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling#building-a-native-executable. \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/build.gradle b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/build.gradle new file mode 100644 index 000000000..8fefe62f7 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/build.gradle @@ -0,0 +1,39 @@ +plugins { + id 'java' + id 'io.quarkus' +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + implementation 'io.quarkus:quarkus-resteasy' + implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + implementation 'io.quarkus:quarkus-resteasy' + + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation 'io.rest-assured:rest-assured' +} + +group 'org.renamed' +version '1.0.0-SNAPSHOT' + +compileJava { + options.encoding = 'UTF-8' + options.compilerArgs << '-parameters' +} + +compileTestJava { + options.encoding = 'UTF-8' +} + +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + +test { + systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" +} diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle.properties b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle.properties new file mode 100644 index 000000000..dde90a579 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle.properties @@ -0,0 +1,6 @@ +#Gradle properties +#Tue Jun 30 18:50:00 UTC 2020 +quarkusPluginVersion=1.5.2.Final +quarkusPlatformArtifactId=quarkus-universe-bom +quarkusPlatformGroupId=io.quarkus +quarkusPlatformVersion=1.5.2.Final \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle/wrapper/gradle-wrapper.properties b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..a4f0001d2 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew new file mode 100755 index 000000000..2fe81a7d9 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or 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 UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# 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"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" + which java >/dev/null 2>&1 || 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 + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew.bat b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew.bat new file mode 100755 index 000000000..9109989e3 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/gradlew.bat @@ -0,0 +1,103 @@ +@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=. +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%" == "0" goto init + +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 init + +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 + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +: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 %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="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! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/settings.gradle b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/settings.gradle new file mode 100644 index 000000000..aab240b07 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/settings.gradle @@ -0,0 +1,11 @@ +pluginManagement { + repositories { + mavenLocal() + mavenCentral() + gradlePluginPortal() + } + plugins { + id 'io.quarkus' version "${quarkusPluginVersion}" + } +} +rootProject.name='my-gradle-project' \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.jvm b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.jvm new file mode 100644 index 000000000..c6fcf7f48 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.jvm @@ -0,0 +1,54 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the docker image run: +# +# mvn package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/renamed-gradle-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/renamed-gradle-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/renamed-gradle-jvm +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 + +ARG JAVA_PACKAGE=java-11-openjdk-headless +ARG RUN_JAVA_VERSION=1.3.8 + +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' + +# Install java and the run-java script +# Also set up permissions for user `1001` +RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ + && microdnf update \ + && microdnf clean all \ + && mkdir /deployments \ + && chown 1001 /deployments \ + && chmod "g+rwX" /deployments \ + && chown 1001:root /deployments \ + && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ + && chown 1001 /deployments/run-java.sh \ + && chmod 540 /deployments/run-java.sh \ + && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security + +# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" + +COPY build/lib/* /deployments/lib/ +COPY build/*-runner.jar /deployments/app.jar + +EXPOSE 8080 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.native b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.native new file mode 100644 index 000000000..bb5da60a8 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/docker/Dockerfile.native @@ -0,0 +1,24 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Before building the docker image run: +# +# mvn package -Pnative -Dquarkus.native.container-build=true +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/renamed-gradle . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/renamed-gradle +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 +WORKDIR /work/ +COPY --chown=1001:root build/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/java/org/renamed/GreetingResource.java b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/java/org/renamed/GreetingResource.java new file mode 100644 index 000000000..fdde04ce4 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/java/org/renamed/GreetingResource.java @@ -0,0 +1,16 @@ +package org.renamed; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +@Path("/hello") +public class GreetingResource { + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String hello() { + return "hello"; + } +} \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/META-INF/resources/index.html b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/META-INF/resources/index.html new file mode 100644 index 000000000..978b932c9 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,155 @@ + + + + + renamed-gradle - 1.0.0-SNAPSHOT + + + + + + +
+
+

Congratulations, you have created a new Quarkus application.

+ +

Why do you see this?

+ +

This page is served by Quarkus. The source is in + src/main/resources/META-INF/resources/index.html.

+ +

What can I do from here?

+ +

If not already done, run the application in dev mode using: mvn compile quarkus:dev. +

+
    +
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • +
  • Your static assets are located in src/main/resources/META-INF/resources.
  • +
  • Configure your application in src/main/resources/application.properties. +
  • +
+ +

Do you like Quarkus?

+

Go give it a star on GitHub.

+ +

How do I get rid of this page?

+

Just delete the src/main/resources/META-INF/resources/index.html file.

+
+
+
+

Application

+
    +
  • GroupId: org.renamed
  • +
  • ArtifactId: renamed-gradle
  • +
  • Version: 1.0.0-SNAPSHOT
  • +
  • Quarkus Version: 1.5.2.Final
  • +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/application.properties b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/application.properties new file mode 100644 index 000000000..75b9417d6 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/main/resources/application.properties @@ -0,0 +1,2 @@ +# Configuration file +# key = value diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/native-test/java/org/renamed/NativeGreetingResourceIT.java b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/native-test/java/org/renamed/NativeGreetingResourceIT.java new file mode 100644 index 000000000..9a003b109 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/native-test/java/org/renamed/NativeGreetingResourceIT.java @@ -0,0 +1,9 @@ +package org.renamed; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class NativeGreetingResourceIT extends GreetingResourceTest { + + // Execute the same tests but in native mode. +} \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/test/java/org/renamed/GreetingResourceTest.java b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/test/java/org/renamed/GreetingResourceTest.java new file mode 100644 index 000000000..0be9ab624 --- /dev/null +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/projects/gradle/renamed-gradle/src/test/java/org/renamed/GreetingResourceTest.java @@ -0,0 +1,21 @@ +package org.renamed; + +import io.quarkus.test.junit.QuarkusTest; +import org.junit.jupiter.api.Test; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +@QuarkusTest +public class GreetingResourceTest { + + @Test + public void testHelloEndpoint() { + given() + .when().get("/hello") + .then() + .statusCode(200) + .body(is("hello")); + } + +} \ No newline at end of file diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/BasePropertiesManagerTest.java b/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/BasePropertiesManagerTest.java index a8f4e53da..3447161f7 100644 --- a/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/BasePropertiesManagerTest.java +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/BasePropertiesManagerTest.java @@ -90,7 +90,8 @@ public String getName() { public enum GradleProjectName { empty_gradle_project("empty-gradle-project"), // - quarkus_gradle_project("quarkus-gradle-project"); + quarkus_gradle_project("quarkus-gradle-project"), // + renamed_quarkus_gradle_project("renamed-gradle"); private final String name; @@ -146,7 +147,7 @@ private static IJavaProject loadJavaProject(String projectName, String parentDir IPath path = new Path(new File(projectFolder, "/.project").getAbsolutePath()); IProjectDescription description = ResourcesPlugin.getWorkspace().loadProjectDescription(path); - IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName()); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (!project.exists()) { project.create(description, null); project.open(null); diff --git a/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelTest.java b/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelTest.java index 4460cec05..95e762574 100644 --- a/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelTest.java +++ b/microprofile.jdt/com.redhat.microprofile.jdt.test/src/main/java/com/redhat/microprofile/jdt/core/ProjectLabelTest.java @@ -78,7 +78,27 @@ public void getProjectLabelMultipleProjects() throws Exception { assertLabels(projectLabelEntries, gradle, "gradle"); } - private void assertProjectLabelInfoContainsProject(List projectLabelEntries, + @Test + public void projectNameMaven() throws Exception { + IJavaProject quarkusMaven = BasePropertiesManagerTest.loadMavenProject(MavenProjectName.using_vertx); + IJavaProject maven = BasePropertiesManagerTest.loadMavenProject(MavenProjectName.empty_maven_project); + List projectLabelEntries = ProjectLabelManager.getInstance().getProjectLabelInfo(); + assertName(projectLabelEntries, quarkusMaven, "using-vertx"); + assertName(projectLabelEntries, maven, "empty-maven-project"); + } + + @Test + public void projectNameGradle() throws Exception { + IJavaProject quarkusGradle = BasePropertiesManagerTest.loadGradleProject(GradleProjectName.quarkus_gradle_project); + IJavaProject gradle = BasePropertiesManagerTest.loadGradleProject(GradleProjectName.empty_gradle_project); + IJavaProject renamedGradle = BasePropertiesManagerTest.loadGradleProject(GradleProjectName.renamed_quarkus_gradle_project); + List projectLabelEntries = ProjectLabelManager.getInstance().getProjectLabelInfo(); + assertName(projectLabelEntries, quarkusGradle, "quarkus-gradle-project"); + assertName(projectLabelEntries, gradle, "empty-gradle-project"); + assertName(projectLabelEntries, renamedGradle, "renamed-gradle"); + } + + private static void assertProjectLabelInfoContainsProject(List projectLabelEntries, IJavaProject... javaProjects) throws CoreException { List actualProjectPaths = projectLabelEntries.stream().map(e -> e.getUri()) .collect(Collectors.toList()); @@ -87,7 +107,7 @@ private void assertProjectLabelInfoContainsProject(List p } } - private void assertLabels(List projectLabelEntries, IJavaProject javaProject, + private static void assertLabels(List projectLabelEntries, IJavaProject javaProject, String... expectedLabels) throws CoreException { String javaProjectPath = JDTMicroProfileUtils.getProjectURI(javaProject.getProject()); List actualLabels = getLabelsFromProjectPath(projectLabelEntries, javaProjectPath); @@ -100,7 +120,20 @@ private void assertLabels(List projectLabelEntries, IJava } } - private List getLabelsFromProjectPath(List projectLabelEntries, String projectPath) { + private static void assertName(List projectLabelEntries, IJavaProject javaProject, + String expectedName) { + String javaProjectPath = JDTMicroProfileUtils.getProjectURI(javaProject.getProject()); + String actualName = null; + for (ProjectLabelInfoEntry entry : projectLabelEntries) { + if (entry.getUri().equals(javaProjectPath)) { + actualName = entry.getName(); + break; + } + } + Assert.assertEquals("Test project name in label", expectedName, actualName); + } + + private static List getLabelsFromProjectPath(List projectLabelEntries, String projectPath) { for (ProjectLabelInfoEntry entry : projectLabelEntries) { if (entry.getUri().equals(projectPath)) { return entry.getLabels(); @@ -109,7 +142,7 @@ private List getLabelsFromProjectPath(List projec return Collections.emptyList(); } - private void assertContains(List list, String strToFind) { + private static void assertContains(List list, String strToFind) { for (String str : list) { if (str.equals(strToFind)) { return;