You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/09/15 08:20:53 UTC

[tomcat-jakartaee-migration] branch main updated (ddc2f11 -> 2c0552a)

This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git


    from ddc2f11  Additional Profile to Migrate Back to JEE8 from Jakarta EE
     new d6ed7d7  Add #28 to change log and expand usage notes
     new 41a9060  Add Checkstyle to build - configuration based on Tomcat 10.1.x
     new 2c0552a  Fix Checkstyle errors

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.md                                         |  1 +
 pom.xml                                            | 21 +++++
 res/checkstyle/checkstyle.xml                      | 93 ++++++++++++++++++++++
 res/checkstyle/header-al2.txt                      | 19 +++++
 .../org/apache/tomcat/jakartaee/AntHandler.java    |  4 +-
 .../apache/tomcat/jakartaee/ClassConverter.java    |  1 +
 .../org/apache/tomcat/jakartaee/EESpecProfile.java | 10 +--
 .../org/apache/tomcat/jakartaee/GlobMatcher.java   |  8 +-
 .../org/apache/tomcat/jakartaee/Migration.java     | 13 ++-
 .../tomcat/jakartaee/LocalStrings.properties       | 10 ++-
 10 files changed, 159 insertions(+), 21 deletions(-)
 create mode 100644 res/checkstyle/checkstyle.xml
 create mode 100644 res/checkstyle/header-al2.txt


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 03/03: Fix Checkstyle errors

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git

commit 2c0552ab668100dfb5677c366d43f64f49470d5d
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 15 09:20:47 2022 +0100

    Fix Checkstyle errors
---
 src/main/java/org/apache/tomcat/jakartaee/AntHandler.java   |  4 ++--
 .../java/org/apache/tomcat/jakartaee/ClassConverter.java    |  1 +
 .../java/org/apache/tomcat/jakartaee/EESpecProfile.java     | 10 +++++-----
 src/main/java/org/apache/tomcat/jakartaee/GlobMatcher.java  |  8 ++------
 src/main/java/org/apache/tomcat/jakartaee/Migration.java    | 13 +++++++++----
 5 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/src/main/java/org/apache/tomcat/jakartaee/AntHandler.java b/src/main/java/org/apache/tomcat/jakartaee/AntHandler.java
index e7747b7..5946226 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/AntHandler.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/AntHandler.java
@@ -27,11 +27,11 @@ import org.apache.tools.ant.Task;
 /**
  * JUL log handler redirecting the messages logged to Ant.
  */
- class AntHandler extends Handler {
+class AntHandler extends Handler {
 
     private final Task task;
 
-    public AntHandler(Task task) {
+    AntHandler(Task task) {
         this.task = task;
     }
 
diff --git a/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java b/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
index da9ee42..8b4116d 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/ClassConverter.java
@@ -26,6 +26,7 @@ import java.lang.instrument.IllegalClassFormatException;
 import java.security.ProtectionDomain;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import org.apache.bcel.classfile.ClassParser;
 import org.apache.bcel.classfile.Constant;
 import org.apache.bcel.classfile.ConstantUtf8;
diff --git a/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
index 23eecbc..8ed0d91 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
@@ -24,7 +24,7 @@ import java.util.regex.Pattern;
  */
 public enum EESpecProfile {
 
-    TOMCAT("javax", "jakarta", 
+    TOMCAT("javax", "jakarta",
             "javax([/\\.](annotation(?![/\\.]processing)" +
             "|ejb" +
             "|el" +
@@ -35,7 +35,7 @@ public enum EESpecProfile {
             "|transaction(?![/\\.]xa)" +
             "|websocket))"),
 
-    EE("javax", "jakarta", 
+    EE("javax", "jakarta",
             "javax([/\\.](activation" +
             "|annotation(?![/\\.]processing)" +
             "|batch" +
@@ -60,7 +60,7 @@ public enum EESpecProfile {
             "|websocket" +
             "|ws[/\\.]rs" +
             "|xml[/\\.](bind|soap|ws)))"),
-    JEE8("jakarta", "javax", 
+    JEE8("jakarta", "javax",
             "jakarta([/\\.](activation" +
             "|annotation(?![/\\.]processing)" +
             "|batch" +
@@ -100,12 +100,12 @@ public enum EESpecProfile {
         Matcher m = pattern.matcher(name);
         return m.replaceAll(target + "$1");
     }
-    
+
     public String getSource()
     {
         return source;
     }
-    
+
     public String getTarget()
     {
         return target;
diff --git a/src/main/java/org/apache/tomcat/jakartaee/GlobMatcher.java b/src/main/java/org/apache/tomcat/jakartaee/GlobMatcher.java
index 33dc338..87bff59 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/GlobMatcher.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/GlobMatcher.java
@@ -233,11 +233,7 @@ public final class GlobMatcher {
         return true;
     }
 
-    private static boolean different(
-        boolean caseSensitive, char ch, char other) {
-        return caseSensitive
-            ? ch != other
-            : Character.toUpperCase(ch) != Character.toUpperCase(other);
+    private static boolean different(boolean caseSensitive, char ch, char other) {
+        return caseSensitive ? ch != other : Character.toUpperCase(ch) != Character.toUpperCase(other);
     }
-
 }
diff --git a/src/main/java/org/apache/tomcat/jakartaee/Migration.java b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
index d8b899c..35bfcbe 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/Migration.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
@@ -195,7 +195,7 @@ public class Migration {
         boolean inplace = src.equals(dest);
         if (!inplace) {
             try (InputStream is = new FileInputStream(src);
-                 OutputStream os = new FileOutputStream(dest)) {
+                    OutputStream os = new FileOutputStream(dest)) {
                 migrateStream(src.getName(), is, os);
             }
         } else {
@@ -283,8 +283,12 @@ public class Migration {
 
 
     private boolean isSignatureFile(String sourceName) {
-        return sourceName.startsWith("META-INF/")
-                && (sourceName.endsWith(".SF") || sourceName.endsWith(".RSA") || sourceName.endsWith(".DSA") || sourceName.endsWith(".EC"));
+        return sourceName.startsWith("META-INF/") && (
+                sourceName.endsWith(".SF") ||
+                sourceName.endsWith(".RSA") ||
+                sourceName.endsWith(".DSA") ||
+                sourceName.endsWith(".EC")
+                );
     }
 
 
@@ -334,7 +338,8 @@ public class Migration {
     }
 
     private static class MigrationZipArchiveEntry extends ZipArchiveEntry {
-        public MigrationZipArchiveEntry(ZipArchiveEntry entry) throws ZipException {
+
+        MigrationZipArchiveEntry(ZipArchiveEntry entry) throws ZipException {
             super(entry);
         }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 02/03: Add Checkstyle to build - configuration based on Tomcat 10.1.x

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git

commit 41a9060cd0fde5d4e70f781d2581c894c1381146
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 15 09:20:38 2022 +0100

    Add Checkstyle to build - configuration based on Tomcat 10.1.x
---
 pom.xml                       | 21 ++++++++++
 res/checkstyle/checkstyle.xml | 93 +++++++++++++++++++++++++++++++++++++++++++
 res/checkstyle/header-al2.txt | 19 +++++++++
 3 files changed, 133 insertions(+)

diff --git a/pom.xml b/pom.xml
index 18a5ca6..8a92cf2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -320,6 +320,27 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <version>3.2.0</version>
+        <configuration>
+          <configLocation>res/checkstyle/checkstyle.xml</configLocation>
+          <headerLocation>res/checkstyle/header-al2.txt</headerLocation>
+          <consoleOutput>true</consoleOutput>
+          <failsOnError>true</failsOnError>
+          <linkXRef>false</linkXRef>
+        </configuration>
+        <executions>
+          <execution>
+            <id>validate</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>check</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/res/checkstyle/checkstyle.xml b/res/checkstyle/checkstyle.xml
new file mode 100644
index 0000000..f79466a
--- /dev/null
+++ b/res/checkstyle/checkstyle.xml
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!DOCTYPE module PUBLIC
+    "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
+    "https://checkstyle.org/dtds/configuration_1_3.dtd">
+<module name="Checker">
+  <!-- When adding checks, keep to the order checks are listed under         -->
+  <!-- 'Standard Checks' in the Checkstyle documentation:                    -->
+  <!-- http://checkstyle.sourceforge.net/config_coding.html                  -->
+
+  <!-- Headers -->
+  <module name="RegexpHeader">
+    <property name="headerFile" value="${checkstyle.header.file}"/>
+    <property name="multiLines" value="1, 2, 3, 4"/>
+    <property name="fileExtensions" value="java,xml,jsp,txt,sh,bat,properties,yaml"/>
+  </module>
+
+  <!-- Whitespace -->
+  <module name="FileTabCharacter"/>
+  <module name="RegexpSingleline">
+    <!-- No trailing whitespace -->
+    <property name="format" value="\s+$"/>
+  </module>
+
+  <module name="TreeWalker">
+
+    <!-- Annotations -->
+    <module name="AnnotationLocation"/>
+    <module name="AnnotationUseStyle"/>
+    <module name="MissingOverride"/>
+    <module name="PackageAnnotation"/>
+
+    <!-- Block Checks -->
+    <module name="AvoidNestedBlocks">
+      <property name="allowInSwitchCase" value="true"/>
+    </module>
+    <module name="NeedBraces"/>
+
+    <!-- Coding -->
+    <module name="IllegalInstantiation"/>
+
+    <!-- Imports -->
+    <module name="AvoidStarImport"/>
+    <module name="AvoidStaticImport">
+        <property name="excludes" value="org.apache.catalina.startup.SimpleHttpClient.CRLF"/>
+        <property name="excludes" value="org.hamcrest.MatcherAssert.*"/>
+        <property name="excludes" value="org.hamcrest.core.IsInstanceOf.*"/>
+    </module>
+    <module name="IllegalImport">
+        <property name="illegalPkgs" value="sun,junit.framework"/>
+    </module>
+    <module name="ImportOrder">
+        <property name="groups" value="java,javax,jakarta,org.hamcrest,org.junit,org,async,jsp2,util"/>
+        <property name="ordered" value="true"/>
+        <property name="separated" value="true"/>
+        <property name="option" value="above"/>
+    </module>
+    <module name="RedundantImport"/>
+    <module name="UnusedImports"/>
+
+    <!-- Miscellaneous -->
+    <module name="Indentation">
+        <property name="lineWrappingIndentation" value="8"/>
+    </module>
+
+    <!-- Modifiers -->
+    <module name="ModifierOrder"/>
+    <module name="RedundantModifier"/>
+
+    <!-- Whitespace -->
+    <module name="GenericWhitespace"/>
+    <module name="EmptyForInitializerPad"/>
+    <module name="EmptyForIteratorPad"/>
+    <module name="OperatorWrap">
+      <property name="option" value="eol"/>
+    </module>
+  </module>
+</module>
diff --git a/res/checkstyle/header-al2.txt b/res/checkstyle/header-al2.txt
new file mode 100644
index 0000000..7234793
--- /dev/null
+++ b/res/checkstyle/header-al2.txt
@@ -0,0 +1,19 @@
+^<\?xml.*>$
+^@echo off$
+^#!
+^\W*$
+^(rem)?\W*Licensed to the Apache Software Foundation \(ASF\) under one or more$
+^(rem)?\W*contributor license agreements\.  See the NOTICE file distributed with$
+^(rem)?\W*this work for additional information regarding copyright ownership\.$
+^(rem)?\W*The ASF licenses this file to You under the Apache License, Version 2\.0$
+^(rem)?\W*\(the "License"\); you may not use this file except in compliance with$
+^(rem)?\W*the License\.  You may obtain a copy of the License at$
+^(rem)?\W*$
+^(rem)?\W*http://www.apache.org/licenses/LICENSE-2\.0$
+^(rem)?\W*$
+^(rem)?\W*Unless required by applicable law or agreed to in writing, software$
+^(rem)?\W*distributed under the License is distributed on an "AS IS" BASIS,$
+^(rem)?\W*WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$
+^(rem)?\W*See the License for the specific language governing permissions and$
+^(rem)?\W*limitations under the License\.$
+^(rem)?\W*$
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 01/03: Add #28 to change log and expand usage notes

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git

commit d6ed7d74cf64812fe198f631fb88c70351dbbef7
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Sep 15 09:20:02 2022 +0100

    Add #28 to change log and expand usage notes
---
 CHANGES.md                                                     |  1 +
 .../org/apache/tomcat/jakartaee/LocalStrings.properties        | 10 ++++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index d724e8d..486a4c7 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -3,6 +3,7 @@
 ## 1.0.4 (in progress)
 
 - Correct a wrong implementation in the previous fix for [#29](https://github.com/apache/tomcat-jakartaee-migration/issues/29) (lihan)
+- Add support for a JEE8 profile that attempts to migrate code using the Jakarta EE APIs to Java EE 8. Note that this will fail if the code uses any APIs added in Jakarta EE 10 onwards. PR #28 provided by blasss.
 
 ## 1.0.3
 
diff --git a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
index d3a63bc..6ee3665 100644
--- a/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
+++ b/src/main/resources/org/apache/tomcat/jakartaee/LocalStrings.properties
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 classConverter.converted=Migrated class [{0}]
-classConverter.noConversion=No conversion necessary for [{0}] 
+classConverter.noConversion=No conversion necessary for [{0}]
 classConverter.skipName=Skip conversion of class usage from the [{0}] namespace to [{1}] as it is not accessible to the classloader
 
 migration.archive.complete=Migration finished for archive [{0}]
@@ -38,7 +38,9 @@ where options includes:\n\
 \    -profile=<profile name>\n\
 \                TOMCAT (default) to convert Java EE APIs provided by Tomcat\n\
 \                EE to convert all Java EE APIs\n\
-\                JEE8 to convert back to old Java EE8 APIs\n\
+\                JEE8 to convert back to old Java EE8 APIs. Note that the\n\
+\                    resulting classes will not work if the classes to be\n\
+\                    migrated use any APIs added in Jakarta EE 10 onwards.\n\
 \    -zipInMemory\n\
 \                By default zip format archives (.zip, jar, .war, .ear, etc.)\n\
 \                are processed as streams. This is more efficient but is not\n\
@@ -49,7 +51,7 @@ where options includes:\n\
 \                able to handle a wider range of zip archive structures.
 migration.warnSignatureRemoval=Removed cryptographic signature from JAR file
 
-passThroughConverter.noConversion=No conversion necessary for [{0}] 
+passThroughConverter.noConversion=No conversion necessary for [{0}]
 
 textConverter.converted=Migrated text file [{0}]
-textConverter.noConversion=No conversion necessary for [{0}] 
+textConverter.noConversion=No conversion necessary for [{0}]


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org