This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new fe768c5655 Remove export / backport code - no longer required for 9.0.x
fe768c5655 is described below
commit fe768c565572037d70afd32c0de81d0accb44718
Author: Mark Thomas <[email protected]>
AuthorDate: Thu May 23 13:36:41 2024 +0100
Remove export / backport code - no longer required for 9.0.x
---
.../tomcat/buildutil/translate/BackportBase.java | 65 ----------------
.../buildutil/translate/BackportEnglish.java | 67 ----------------
.../buildutil/translate/BackportTranslations.java | 68 -----------------
.../tomcat/buildutil/translate/Constants.java | 2 -
.../apache/tomcat/buildutil/translate/Utils.java | 89 ----------------------
.../tomcat/buildutil/translate/TestUtils.java | 18 -----
6 files changed, 309 deletions(-)
diff --git a/java/org/apache/tomcat/buildutil/translate/BackportBase.java
b/java/org/apache/tomcat/buildutil/translate/BackportBase.java
deleted file mode 100644
index 1a7ab7ed8e..0000000000
--- a/java/org/apache/tomcat/buildutil/translate/BackportBase.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.tomcat.buildutil.translate;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * Base class providing common implementation for back-port utilities.
- */
-public abstract class BackportBase {
-
- protected final Map<String,Properties> sourceTranslations = new
HashMap<>();
- protected final Map<String,Properties> targetTranslations = new
HashMap<>();
- protected final File targetRoot;
- protected final Properties sourceEnglish;
- protected final Properties targetEnglish;
- protected final File storageDir;
-
- protected BackportBase(String... args) throws IOException {
- if (args.length != 1) {
- throw new IllegalArgumentException("Missing back-port target");
- }
- targetRoot = new File(args[0]);
-
- if (!targetRoot.isDirectory()) {
- throw new IllegalArgumentException("Back-port target not a
directory");
- }
-
- File sourceRoot = new File(".");
- for (String dir : Constants.SEARCH_DIRS) {
- File directory = new File(dir);
- Utils.processDirectory(sourceRoot, directory, sourceTranslations);
- }
-
- for (String dir : Constants.SEARCH_DIRS) {
- File directory = new File(targetRoot, dir);
- Utils.processDirectory(targetRoot, directory, targetTranslations);
- }
-
- sourceEnglish = sourceTranslations.get("");
- targetEnglish = targetTranslations.get("");
-
- storageDir = new File(targetRoot, Constants.STORAGE_DIR);
- }
-
- protected abstract void execute() throws IOException;
-}
diff --git a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
b/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
deleted file mode 100644
index 8fd8b61a3e..0000000000
--- a/java/org/apache/tomcat/buildutil/translate/BackportEnglish.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.tomcat.buildutil.translate;
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Generates a set of English property files to back-port updates to a previous
- * version. Where a key exists in the source and target versions the value is
- * copied from the source to the target, overwriting the value in the target.
- * The expectation is that the changes will be manually reviewed before
- * committing them.
- */
-public class BackportEnglish extends BackportBase {
-
- private static Set<String> keysToExclude = new HashSet<>();
-
-
- public static void main(String... args) throws IOException {
- // Exclude keys known to be different between all versions
-
keysToExclude.add("java.org.apache.jasper.resources.zzz.jsp.error.jsproot.version.invalid");
-
keysToExclude.add("java.org.apache.jasper.resources.zzz.jspc.webfrg.header");
-
keysToExclude.add("java.org.apache.jasper.resources.zzz.jspc.webxml.header");
-
- // Exclude keys known to be different between 9.0.x and 8.5.x
-
keysToExclude.add("java.org.apache.catalina.manager.zzz.htmlManagerServlet.deployPath");
-
keysToExclude.add("java.org.apache.catalina.startup.zzz.catalina.stopServer.connectException");
- keysToExclude.add("java.org.apache.jasper.resources.zzz.jspc.usage");
-
keysToExclude.add("java.org.apache.tomcat.dbcp.dbcp2.zzz.connectionFactory.lifetimeExceeded");
-
- BackportEnglish backport = new BackportEnglish(args);
- backport.execute();
- }
-
-
- protected BackportEnglish(String[] args) throws IOException {
- super(args);
- }
-
-
- @Override
- protected void execute() throws IOException {
- for (Object key : sourceEnglish.keySet()) {
- if (targetEnglish.containsKey(key) &&
!keysToExclude.contains(key)) {
- targetEnglish.put(key, sourceEnglish.get(key));
- }
- }
-
- Utils.export("", targetEnglish, storageDir);
- }
-}
diff --git
a/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
b/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
deleted file mode 100644
index ff493224de..0000000000
--- a/java/org/apache/tomcat/buildutil/translate/BackportTranslations.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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 org.apache.tomcat.buildutil.translate;
-
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * Generates a set of translated property files to back-port updates to a
- * previous version. If the source and target use the same value for the
English
- * key then any translated value for that key is copied from the source to the
- * target.
- */
-public class BackportTranslations extends BackportBase {
-
- public static void main(String... args) throws IOException {
- BackportTranslations backport = new BackportTranslations(args);
- backport.execute();
- }
-
- protected BackportTranslations(String[] args) throws IOException {
- super(args);
- }
-
-
- @Override
- protected void execute() throws IOException {
- for (String language : targetTranslations.keySet()) {
- // Skip source
- if (language.length() == 0) {
- continue;
- }
-
- Properties sourceTranslated = sourceTranslations.get(language);
- Properties targetTranslated = targetTranslations.get(language);
- if (targetTranslated == null) {
- targetTranslated = new Properties();
- targetTranslations.put(language, targetTranslated);
- }
-
- for (Object key : targetEnglish.keySet()) {
- if (sourceTranslated.containsKey(key) &&
- targetEnglish.get(key).equals(sourceEnglish.get(key)))
{
-
- targetTranslated.put(key, sourceTranslated.get(key));
- }
- }
-
- // Remove translated values for keys that have been removed
- targetTranslated.entrySet().removeIf(entry ->
!targetEnglish.containsKey(entry.getKey()));
- Utils.export(language, targetTranslated, storageDir);
- }
- }
-}
diff --git a/java/org/apache/tomcat/buildutil/translate/Constants.java
b/java/org/apache/tomcat/buildutil/translate/Constants.java
index c156df976c..d372ad9b88 100644
--- a/java/org/apache/tomcat/buildutil/translate/Constants.java
+++ b/java/org/apache/tomcat/buildutil/translate/Constants.java
@@ -21,8 +21,6 @@ public class Constants {
public static final String L10N_PREFIX = "LocalStrings";
public static final String L10N_SUFFIX = ".properties";
- public static final String[] SEARCH_DIRS = new String[] { "java",
"webapps" };
-
public static final String STORAGE_DIR = ".settings/translations";
public static final String END_PACKAGE_MARKER = ".zzz.";
diff --git a/java/org/apache/tomcat/buildutil/translate/Utils.java
b/java/org/apache/tomcat/buildutil/translate/Utils.java
index b4ebf1c54f..af2949e5a1 100644
--- a/java/org/apache/tomcat/buildutil/translate/Utils.java
+++ b/java/org/apache/tomcat/buildutil/translate/Utils.java
@@ -18,16 +18,11 @@ package org.apache.tomcat.buildutil.translate;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
import java.io.Reader;
-import java.io.Writer;
import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
import java.util.HashSet;
-import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
@@ -71,19 +66,6 @@ public class Utils {
}
- static String formatValueExport(String in) {
- String result;
-
- if (in.startsWith("\n")) {
- result = PADDING + in;
- } else {
- result = in;
- }
-
- return formatValueCommon(result);
- }
-
-
static String formatValueImport(String in) {
String result;
@@ -127,75 +109,4 @@ public class Utils {
return result;
}
-
-
- static void processDirectory(File root, File dir, Map<String,Properties>
translations) throws IOException {
- File[] files = dir.listFiles();
- if (files == null) {
- throw new IllegalArgumentException("Not a directory [" +
dir.getAbsolutePath() + "]");
- }
- for (File f : files) {
- if (f.isDirectory()) {
- processDirectory(root, f, translations);
- } else if (f.isFile()) {
- processFile(root, f, translations);
- }
- }
- }
-
-
- static void processFile(File root, File f, Map<String,Properties>
translations) throws IOException {
- String name = f.getName();
-
- // non-l10n files
- if (!name.startsWith(Constants.L10N_PREFIX)) {
- return;
- }
-
- // Determine language
- String language = getLanguage(name);
-
- String keyPrefix = getKeyPrefix(root, f);
- Properties props = load(f);
-
- // Create a Map for the language if one does not exist.
- Properties translation = translations.get(language);
- if (translation == null) {
- translation = new Properties();
- translations.put(language, translation);
- }
-
- // Add the properties from this file to the combined file, prefixing
the
- // key with the package name to ensure uniqueness.
- for (Object obj : props.keySet()) {
- String key = (String) obj;
- String value = props.getProperty(key);
-
- translation.put(keyPrefix + key, value);
- }
- }
-
-
- static String getKeyPrefix(File root, File f) throws IOException {
- String prefix = f.getParentFile().getCanonicalPath();
- prefix = prefix.substring(root.getCanonicalPath().length() + 1);
- prefix = prefix.replace(File.separatorChar, '.');
- prefix = prefix + Constants.END_PACKAGE_MARKER;
- return prefix;
- }
-
-
- static void export(String language, Properties translation, File
storageDir) {
- File out = new File(storageDir, Constants.L10N_PREFIX + language +
Constants.L10N_SUFFIX);
- try (FileOutputStream fos = new FileOutputStream(out);
- Writer w = new OutputStreamWriter(fos,
StandardCharsets.UTF_8)) {
- String[] keys = translation.keySet().toArray(new String[0]);
- Arrays.sort(keys);
- for (Object key : keys) {
- w.write(key + "=" +
formatValueExport(translation.getProperty((String) key)) + "\n");
- }
- } catch (IOException ioe) {
- ioe.printStackTrace();
- }
- }
}
diff --git a/test/org/apache/tomcat/buildutil/translate/TestUtils.java
b/test/org/apache/tomcat/buildutil/translate/TestUtils.java
index d2d549043e..250f8aedf5 100644
--- a/test/org/apache/tomcat/buildutil/translate/TestUtils.java
+++ b/test/org/apache/tomcat/buildutil/translate/TestUtils.java
@@ -58,22 +58,4 @@ public class TestUtils {
// Import from POEditor
Assert.assertEquals("\\n\\\n</web-fragment>\\n",
Utils.formatValueImport("\\n</web-fragment>\\n"));
}
-
- @Test
- public void testFormatValue03() {
- // Export from Tomcat
- Assert.assertEquals("line1\\n\\\nline2\\n\\\nline3",
Utils.formatValueExport("line1\nline2\nline3"));
- }
-
- @Test
- public void testFormatValue04() {
- // Export from Tomcat
- Assert.assertEquals(Utils.PADDING + "\\n\\\nline2\\n\\\nline3",
Utils.formatValueExport("\nline2\nline3"));
- }
-
- @Test
- public void testFormatValue05() {
- // Export from Tomcat
- Assert.assertEquals("line1\\n\\\n\\tline2\\n\\\n\\tline3",
Utils.formatValueExport("line1\n\tline2\n\tline3"));
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]