Skip to content

Commit

Permalink
Java 8 deprecation Stage 1 (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohecker authored Apr 3, 2024
1 parent 708d4e4 commit b98865e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions core/src/main/java/com/devonfw/tools/solicitor/Solicitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.devonfw.tools.solicitor.SolicitorCliProcessor.CommandLineOptions;
import com.devonfw.tools.solicitor.SolicitorSetup.ReaderSetup;
import com.devonfw.tools.solicitor.common.DeprecationChecker;
import com.devonfw.tools.solicitor.common.LogMessages;
import com.devonfw.tools.solicitor.common.MavenVersionHelper;
import com.devonfw.tools.solicitor.common.ResourceToFileCopier;
Expand Down Expand Up @@ -66,6 +67,9 @@ public class Solicitor {
@Autowired
private LifecycleListenerHolder lifecycleListenerHolder;

@Autowired
private DeprecationChecker deprecationChecker;

private boolean tolerateMissingInput = false;

@Value("${solicitor.tolerate-missing-input}")
Expand Down Expand Up @@ -111,6 +115,7 @@ private void extractConfig(String targetDir) {
*/
private void mainProcessing(CommandLineOptions clo) {

checkJavaVersion();
ModelRoot modelRoot = this.configFactory.createConfig(clo.configUrl);
this.lifecycleListenerHolder.modelRootInitialized(modelRoot);
if (clo.load) {
Expand All @@ -136,6 +141,20 @@ private void mainProcessing(CommandLineOptions clo) {
this.lifecycleListenerHolder.endOfMainProcessing(modelRoot);
}

/**
* Checks the java version and possibly issue deprecation error or warning.
*/
private void checkJavaVersion() {

String javaVersion = System.getProperty("java.version");
// we just check for the prefix "1." because from Java 9 on the version number does no longer start with "1."
if (javaVersion.startsWith("1.")) {
this.deprecationChecker.check(true,
"Running Solicitor on Java 8 is deprecated. Yours is '" + javaVersion + "'. Switch to Java 11!");
}

}

/**
* Read the inventory of {@link ApplicationComponent}s and their declared licenses.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public enum LogMessages {
DEPRECATIONS_ACTIVE(42,
"Deprecated features are available ({}). Please check if this is necessary. Look for message code '{}' to check for actually used deprecated features."), //
UNAVAILABLE_DEPRECATED_FEATURE(43,
"This featue is deprecated and no longer available. Details: {}. For backward compatibility you might temporary activate it by setting '{}'."), //
"This feature is deprecated and no longer available. Details: {}. For backward compatibility you might temporary activate it by setting '{}'."), //
USING_DEPRECATED_FEATURE_FORCED(44,
"You are using a deprecated feature which is only available because you set {}. You should ASAP migrate your project as this might be unavailable in future versions. Details: {}."), //
MISSING_INVENTORY_INPUT_FILE(45,
Expand Down
4 changes: 3 additions & 1 deletion documentation/master-solicitor.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ A "normalized" license id might be either a SPDX-Id, a `LicenseRef`-Id or a "pse

== Usage
=== Executing Solicitor
_Solicitor_ is a standalone Java (Spring Boot) application. Prerequisite for running it is an existing Java 8 or 11 runtime environment. If you do not yet have a the _Solicitor_ executable JAR (`solicitor.jar`) you need to build it as given on the project GitHub homepage https://github.com/devonfw/solicitor .
_Solicitor_ is a standalone Java (Spring Boot) application. Prerequisite for running it is an existing Java 11 runtime environment. If you do not yet have a the _Solicitor_ executable JAR (`solicitor.jar`) you need to build it as given on the project GitHub homepage https://github.com/devonfw/solicitor .

_Solicitor_ is executed with the following command:

Expand Down Expand Up @@ -1371,6 +1371,7 @@ The following features are deprecated via the above mechanism:
* "REGEX:" prefix notation in rule templates (use "(REGEX)" suffix instead); Stage 1 from Version 1.3.0 on; see https://github.com/devonfw/solicitor/issues/78
* Use of `LicenseAssignmentProject.xls` decision table (use `LicenseAssignmentV2Project.xls` instead); Stage 1 from Version 1.4.0 on
* Use of `repoType` in the configuration of readers, see <<Applications>>; Stage 1 from Version 1.14.0 on; see https://github.com/devonfw/solicitor/issues/190
* Running Solicitor on Java 8; Stage 1 from Version 1.22.0 on; see https://github.com/devonfw/solicitor/issues/247

== Experimental Scancode Integration

Expand Down Expand Up @@ -1701,6 +1702,7 @@ Spring beans implementing this interface will be called at certain points in the
Changes in 1.22.0::
* https://github.com/devonfw/solicitor/pull/243: Make sure the MavenReader is protected against XXE threats.
* https://github.com/devonfw/solicitor/pull/244: Updated Drools rule engine to 8.44.0.Final.
* https://github.com/devonfw/solicitor/issues/247: Running Solicitor on Java 8 is deprecated (Stage 1) and will be no longer possible soon. Move to Java 11 ASAP!

Changes in 1.21.0::
* https://github.com/devonfw/solicitor/pull/239: Improving some internal components to reduce risk of path traversal attacks in case that these components are (re)used in some webservice implementation.
Expand Down

0 comments on commit b98865e

Please sign in to comment.