|
| 1 | +/* |
| 2 | + * Copyright 2017 Google Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.google.cloud.compatchecker; |
| 17 | + |
| 18 | +import com.google.common.collect.ImmutableSet; |
| 19 | +import com.google.common.collect.Lists; |
| 20 | +import java.util.List; |
| 21 | +import java.util.Properties; |
| 22 | +import java.util.Set; |
| 23 | +import kr.motd.maven.os.Detector; |
| 24 | + |
| 25 | +public class GoogleCloudCompatChecker { |
| 26 | + private static Set<String> supportedClassifiers = |
| 27 | + ImmutableSet.of("linux-x86_64", "osx-x86_64", "windows-x86_64"); |
| 28 | + |
| 29 | + private static class OsDetector extends Detector { |
| 30 | + public void detect(Properties props, List<String> classifierWithLikes) { |
| 31 | + super.detect(props, classifierWithLikes); |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + protected void log(String s) { |
| 36 | + // meh |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + protected void logProperty(String s, String s1) { |
| 41 | + // meh |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + public static void main(String[] args) { |
| 46 | + Properties osProperties = new Properties(); |
| 47 | + new OsDetector().detect(osProperties, Lists.<String>newArrayList()); |
| 48 | + System.out.println("OS details:"); |
| 49 | + System.out.println(" " + Detector.DETECTED_NAME + ": " + osProperties.get(Detector.DETECTED_NAME)); |
| 50 | + System.out.println(" " + Detector.DETECTED_ARCH + ": " + osProperties.get(Detector.DETECTED_ARCH)); |
| 51 | + System.out.println(" " + Detector.DETECTED_CLASSIFIER + ": " + osProperties.get(Detector.DETECTED_CLASSIFIER)); |
| 52 | + System.out.println(" " + Detector.DETECTED_RELEASE + ": " + osProperties.get(Detector.DETECTED_RELEASE)); |
| 53 | + System.out.println(" " + Detector.DETECTED_RELEASE_VERSION + ": " + osProperties.get(Detector.DETECTED_RELEASE_VERSION)); |
| 54 | + |
| 55 | + String osClassifier = (String)osProperties.get(Detector.DETECTED_CLASSIFIER); |
| 56 | + |
| 57 | + boolean compatible = true; |
| 58 | + System.out.println("Checking compatibility..."); |
| 59 | + if (supportedClassifiers.contains(osClassifier)) { |
| 60 | + System.out.println(" This OS + architecture is supported by Forked Tomcat Native."); |
| 61 | + } else { |
| 62 | + System.out.println(" This OS + architecture is NOT supported by Forked Tomcat Native."); |
| 63 | + System.out.println(" See http://netty.io/wiki/forked-tomcat-native.html for details."); |
| 64 | + compatible = false; |
| 65 | + } |
| 66 | + if (!compatible) { |
| 67 | + System.out.println("Result: FAIL"); |
| 68 | + } else { |
| 69 | + System.out.println("Result: UNKNOWN (checker implementation not complete)"); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments