com.google.gradle:osdetector-gradle-plugin

A Gradle plugin that detects the OS name and architecture, providing a uniform classifier to be used in the names of native artifacts.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.google.gradle
ArtifactId

ArtifactId

osdetector-gradle-plugin
Last Version

Last Version

1.7.0
Release Date

Release Date

Type

Type

jar
Description

Description

com.google.gradle:osdetector-gradle-plugin
A Gradle plugin that detects the OS name and architecture, providing a uniform classifier to be used in the names of native artifacts.
Project URL

Project URL

https://github.com/google/osdetector-gradle-plugin
Source Code Management

Source Code Management

https://github.com/google/osdetector-gradle-plugin

Download osdetector-gradle-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.google.gradle/osdetector-gradle-plugin/ -->
<dependency>
    <groupId>com.google.gradle</groupId>
    <artifactId>osdetector-gradle-plugin</artifactId>
    <version>1.7.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.google.gradle/osdetector-gradle-plugin/
implementation 'com.google.gradle:osdetector-gradle-plugin:1.7.0'
// https://jarcasting.com/artifacts/com.google.gradle/osdetector-gradle-plugin/
implementation ("com.google.gradle:osdetector-gradle-plugin:1.7.0")
'com.google.gradle:osdetector-gradle-plugin:jar:1.7.0'
<dependency org="com.google.gradle" name="osdetector-gradle-plugin" rev="1.7.0">
  <artifact name="osdetector-gradle-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.google.gradle', module='osdetector-gradle-plugin', version='1.7.0')
)
libraryDependencies += "com.google.gradle" % "osdetector-gradle-plugin" % "1.7.0"
[com.google.gradle/osdetector-gradle-plugin "1.7.0"]

Dependencies

compile (1)

Group / Artifact Type Version
kr.motd.maven : os-maven-plugin jar 1.7.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

OS Detector Plugin for Gradle

A Gradle plugin that detects the OS name and architecture, providing a uniform classifier to be used in the names of native artifacts.

It uses os-maven-plugin under the hood thus produces the same result.

Requires Java 8 or up.

Latest version

The latest version 1.7.0 is available on Maven Central. Its output is identical to os-maven-plugin:1.7.0.

Usage

To use this plugin, include in your build script

For Gradle 2.1 and higher:

plugins {
  id "com.google.osdetector" version "1.7.0"
}

For Gradle 1.x and 2.0:

apply plugin: 'com.google.osdetector'

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.google.gradle:osdetector-gradle-plugin:1.7.0'
  }
}

The plugin creates osdetector extension in your project, through which you can access the following attributes:

  • osdetector.os: normalized OS name
  • osdetector.arch: architecture
  • osdetector.classifier: classifier, which is osdetector.os + '-' + osdetector.arch, e.g., linux-x86_64
  • osdetector.release: only vailable if osdetector.os is linux. null on non-linux systems. It provides additional information about the linux release:
  • id: the ID for the linux release
  • version: the version ID for this linux release
  • isLike(baseRelease): true if this release is a variant of the given base release. For example, ubuntu is a variant of debian, so on a debian or ubuntu system isLike('debian`) returns true.

WARNING: DO NOT USE osdetector.classifierWithLikes because it has a known issue. It will be either removed or changed to a different form in the next version.

Typical usage example

To have separate artifacts for different operating systems

artifacts {
  archives(artifactFile) {
    classifier osdetector.classifier
    type "exe"
    extension "exe"
    builtBy buildArtifact
  }
}

To differentiate between debian-like, redhat-like and

other linux systems

def getLinuxReleaseSuffix() {
  if (osdetector.release.isLike('debian')) {
    return 'debian'
  } else if (osdetector.release.isLike('redhat')) {
    return 'redhat'
  } else {
    return 'other'
  }
}

artifacts {
  archives(artifactFile) {
    classifier osdetector.classifier + '-' + getLinuxReleaseSuffix()
    type "exe"
    extension "exe"
    builtBy buildArtifact
  }
}

To build and install locally

$ git clone [email protected]:google/osdetector-gradle-plugin.git
$ cd osdetector-gradle-plugin
$ ./gradlew install
com.google.gradle

Google

Google ❤️ Open Source

Versions

Version
1.7.0
1.6.2
1.6.1
1.6.0
1.4.0
1.3.1
1.3.0
1.2.1
1.2.0