Package kr.motd.maven.os
Class Detector
- java.lang.Object
-
- kr.motd.maven.os.Detector
-
public abstract class Detector extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDetector.LinuxReleaseprivate static classDetector.SimpleFileOperationsprivate static classDetector.SimpleSystemPropertyOperations
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String[]DEFAULT_REDHAT_VARIANTSstatic java.lang.StringDETECTED_ARCHstatic java.lang.StringDETECTED_BITNESSstatic java.lang.StringDETECTED_CLASSIFIERstatic java.lang.StringDETECTED_NAMEstatic java.lang.StringDETECTED_RELEASEstatic java.lang.StringDETECTED_RELEASE_LIKE_PREFIXstatic java.lang.StringDETECTED_RELEASE_VERSIONstatic java.lang.StringDETECTED_VERSIONstatic java.lang.StringDETECTED_VERSION_MAJORstatic java.lang.StringDETECTED_VERSION_MINORprivate FileOperationProviderfileOperationProviderprivate static java.lang.StringLINUX_ID_LIKE_PREFIXprivate static java.lang.StringLINUX_ID_PREFIXprivate static java.lang.String[]LINUX_OS_RELEASE_FILESprivate static java.lang.StringLINUX_VERSION_ID_PREFIXprivate static java.util.regex.PatternREDHAT_MAJOR_VERSION_REGEXprivate static java.lang.StringREDHAT_RELEASE_FILEprivate SystemPropertyOperationProvidersystemPropertyOperationProviderprivate static java.lang.StringUNKNOWNprivate static java.util.regex.PatternVERSION_REGEX
-
Constructor Summary
Constructors Constructor Description Detector()Detector(SystemPropertyOperationProvider systemPropertyOperationProvider, FileOperationProvider fileOperationProvider)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static voidcloseQuietly(java.io.Closeable obj)protected voiddetect(java.util.Properties props, java.util.List<java.lang.String> classifierWithLikes)private intdetermineBitness(java.lang.String architecture)private Detector.LinuxReleasegetLinuxRelease()static intguessBitnessFromArchitecture(java.lang.String arch)protected abstract voidlog(java.lang.String message)protected abstract voidlogProperty(java.lang.String name, java.lang.String value)private static java.lang.Stringnormalize(java.lang.String value)private static java.lang.StringnormalizeArch(java.lang.String value)private static java.lang.StringnormalizeOs(java.lang.String value)private static java.lang.StringnormalizeOsReleaseValue(java.lang.String value)private Detector.LinuxReleaseparseLinuxOsReleaseFile(java.lang.String fileName)Parses a file in the format of/etc/os-releaseand return aDetector.LinuxReleasebased on theID,ID_LIKE, andVERSION_IDentries.private Detector.LinuxReleaseparseLinuxRedhatReleaseFile(java.lang.String fileName)Parses the/etc/redhat-releaseand returns aDetector.LinuxReleasecontaining the ID and like ["rhel", "fedora", ID].private voidsetProperty(java.util.Properties props, java.lang.String name, java.lang.String value)
-
-
-
Field Detail
-
DETECTED_NAME
public static final java.lang.String DETECTED_NAME
- See Also:
- Constant Field Values
-
DETECTED_ARCH
public static final java.lang.String DETECTED_ARCH
- See Also:
- Constant Field Values
-
DETECTED_BITNESS
public static final java.lang.String DETECTED_BITNESS
- See Also:
- Constant Field Values
-
DETECTED_VERSION
public static final java.lang.String DETECTED_VERSION
- See Also:
- Constant Field Values
-
DETECTED_VERSION_MAJOR
public static final java.lang.String DETECTED_VERSION_MAJOR
- See Also:
- Constant Field Values
-
DETECTED_VERSION_MINOR
public static final java.lang.String DETECTED_VERSION_MINOR
- See Also:
- Constant Field Values
-
DETECTED_CLASSIFIER
public static final java.lang.String DETECTED_CLASSIFIER
- See Also:
- Constant Field Values
-
DETECTED_RELEASE
public static final java.lang.String DETECTED_RELEASE
- See Also:
- Constant Field Values
-
DETECTED_RELEASE_VERSION
public static final java.lang.String DETECTED_RELEASE_VERSION
- See Also:
- Constant Field Values
-
DETECTED_RELEASE_LIKE_PREFIX
public static final java.lang.String DETECTED_RELEASE_LIKE_PREFIX
- See Also:
- Constant Field Values
-
UNKNOWN
private static final java.lang.String UNKNOWN
- See Also:
- Constant Field Values
-
LINUX_ID_PREFIX
private static final java.lang.String LINUX_ID_PREFIX
- See Also:
- Constant Field Values
-
LINUX_ID_LIKE_PREFIX
private static final java.lang.String LINUX_ID_LIKE_PREFIX
- See Also:
- Constant Field Values
-
LINUX_VERSION_ID_PREFIX
private static final java.lang.String LINUX_VERSION_ID_PREFIX
- See Also:
- Constant Field Values
-
LINUX_OS_RELEASE_FILES
private static final java.lang.String[] LINUX_OS_RELEASE_FILES
-
REDHAT_RELEASE_FILE
private static final java.lang.String REDHAT_RELEASE_FILE
- See Also:
- Constant Field Values
-
DEFAULT_REDHAT_VARIANTS
private static final java.lang.String[] DEFAULT_REDHAT_VARIANTS
-
VERSION_REGEX
private static final java.util.regex.Pattern VERSION_REGEX
-
REDHAT_MAJOR_VERSION_REGEX
private static final java.util.regex.Pattern REDHAT_MAJOR_VERSION_REGEX
-
systemPropertyOperationProvider
private final SystemPropertyOperationProvider systemPropertyOperationProvider
-
fileOperationProvider
private final FileOperationProvider fileOperationProvider
-
-
Constructor Detail
-
Detector
public Detector()
-
Detector
public Detector(SystemPropertyOperationProvider systemPropertyOperationProvider, FileOperationProvider fileOperationProvider)
-
-
Method Detail
-
detect
protected void detect(java.util.Properties props, java.util.List<java.lang.String> classifierWithLikes)
-
setProperty
private void setProperty(java.util.Properties props, java.lang.String name, java.lang.String value)
-
log
protected abstract void log(java.lang.String message)
-
logProperty
protected abstract void logProperty(java.lang.String name, java.lang.String value)
-
normalizeOs
private static java.lang.String normalizeOs(java.lang.String value)
-
normalizeArch
private static java.lang.String normalizeArch(java.lang.String value)
-
normalize
private static java.lang.String normalize(java.lang.String value)
-
getLinuxRelease
private Detector.LinuxRelease getLinuxRelease()
-
parseLinuxOsReleaseFile
private Detector.LinuxRelease parseLinuxOsReleaseFile(java.lang.String fileName)
Parses a file in the format of/etc/os-releaseand return aDetector.LinuxReleasebased on theID,ID_LIKE, andVERSION_IDentries.
-
parseLinuxRedhatReleaseFile
private Detector.LinuxRelease parseLinuxRedhatReleaseFile(java.lang.String fileName)
Parses the/etc/redhat-releaseand returns aDetector.LinuxReleasecontaining the ID and like ["rhel", "fedora", ID]. Currently only supported for CentOS, Fedora, and RHEL. Other variants will returnnull.
-
normalizeOsReleaseValue
private static java.lang.String normalizeOsReleaseValue(java.lang.String value)
-
determineBitness
private int determineBitness(java.lang.String architecture)
-
guessBitnessFromArchitecture
public static int guessBitnessFromArchitecture(java.lang.String arch)
-
closeQuietly
private static void closeQuietly(java.io.Closeable obj)
-
-