diff --git a/build.gradle b/build.gradle index 03ea066fec..598a9bf1bf 100644 --- a/build.gradle +++ b/build.gradle @@ -443,19 +443,8 @@ task generateWebapp(type: NpmTask) { args = ['run', 'prod'] } -task versionTxt() { - dependsOn generateWebapp - doLast { - new File(projectDir.getAbsolutePath() + "/src/main/resources", "version.json").text = """{ - "buildTime": "${new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date())}", - "version": "$version" -} -""" - } -} - task finalizeWebapp(type: Copy) { - dependsOn versionTxt + dependsOn generateWebapp // Because of: https://github.com/angular/angular-cli/issues/26304 // we need to copy some things around. from 'webapp/wiremock/dist/browser' diff --git a/src/main/java/com/github/tomakehurst/wiremock/admin/tasks/VersionTask.java b/src/main/java/com/github/tomakehurst/wiremock/admin/tasks/VersionTask.java deleted file mode 100644 index ed50e597c2..0000000000 --- a/src/main/java/com/github/tomakehurst/wiremock/admin/tasks/VersionTask.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2023 Thomas Akehurst - * - * 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 - * - * http://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. - */ -package com.github.tomakehurst.wiremock.admin.tasks; - -import static com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder.responseDefinition; -import static java.net.HttpURLConnection.HTTP_OK; - -import com.github.tomakehurst.wiremock.admin.AdminTask; -import com.github.tomakehurst.wiremock.admin.model.VersionResult; -import com.github.tomakehurst.wiremock.common.Json; -import com.github.tomakehurst.wiremock.common.url.PathParams; -import com.github.tomakehurst.wiremock.core.Admin; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; -import com.github.tomakehurst.wiremock.stubbing.ServeEvent; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - -public class VersionTask implements AdminTask { - - private static VersionResult versionResult; - - static { - try { - InputStream inputStream = VersionTask.class.getResourceAsStream("/version.json"); - String json = readFromInputStream(inputStream); - versionResult = Json.read(json, VersionResult.class); - } catch (IOException e) { - versionResult = new VersionResult("unknown", "unknown"); - } - } - - @Override - public ResponseDefinition execute(Admin admin, ServeEvent serveEvent, PathParams pathParams) { - - return responseDefinition() - .withStatus(HTTP_OK) - .withStatusMessage("Wiremock is ok") - .withBody(Json.write(versionResult)) - .withHeader("Content-Type", "application/json") - .build(); - } - - private static String readFromInputStream(InputStream inputStream) throws IOException { - StringBuilder resultStringBuilder = new StringBuilder(); - try (BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { - String line; - while ((line = br.readLine()) != null) { - resultStringBuilder.append(line).append("\n"); - } - } - return resultStringBuilder.toString(); - } -} diff --git a/webapp/wiremock/src/app/components/home/home.component.html b/webapp/wiremock/src/app/components/home/home.component.html index cd6f983093..20dabce5b9 100644 --- a/webapp/wiremock/src/app/components/home/home.component.html +++ b/webapp/wiremock/src/app/components/home/home.component.html @@ -113,15 +113,10 @@ Shutdown
-- {{ versionTooltip }} --