• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

google/osdetector-gradle-plugin: A Gradle plugin that detects the OS name and ar ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

google/osdetector-gradle-plugin

开源软件地址(OpenSource Url):

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

开源编程语言(OpenSource Language):

Java 73.9%

开源软件介绍(OpenSource Introduction):

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



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap