Git Product home page Git Product logo

osdetector-gradle-plugin's 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.3 is available on Maven Central. Its output is identical to os-maven-plugin:1.7.1.

Usage

To use this plugin, include in your build script

For Gradle 2.1 and higher:

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

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.3'
  }
}

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

osdetector-gradle-plugin's People

Contributors

dpukyle avatar ejona86 avatar ind1go avatar jonnyzzz avatar mikanbako avatar qiangxuhui avatar trustin avatar voidzcy avatar zhangkun83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

osdetector-gradle-plugin's Issues

1.6.0 not available in plugins.gradle.org/m2

The version 1.6.0 of the plugin is not accessible

https://plugins.gradle.org/m2/gradle/plugin/com/google/gradle/osdetector-gradle-plugin/1.6.0/

osdetector-gradle-plugin-1.6.0.jar

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>
gradle.plugin.com.google.gradle/osdetector-gradle-plugin/1.6.0/e074d3daa0ca0e5a0c6e2c98fcd9da6645ac520c8d091612ae58bdcde65d0585/osdetector-gradle-plugin-1.6.0.jar
</Key>
<RequestId>3C8CE86E331C7F5E</RequestId>
<HostId>
4KAux3R5OCNzgq4rDdQPaU6tU9amZxTb07yxbCtddy0wnL7XGbWItn5hCbq51oh5
</HostId>
</Error>

The plugin should not use the deprecated org.gradle.util.VersionNumber

In Gradle 7.1, org.gradle.util.VersionNumber has been soft deprecated (@deprecated annotation).

For Gradle 7.6 we wanted to add deprecation nagging to it. Our smoke tests show that the osdetector Gradle plugin still uses the VersionNumber. We will postpone adding the deprecation nagging because users currently cannot resolve it.

Could you please look into removing that usage from the plugin? You can use GradleVersion instead.

build osdetector-gradle-plugin for mips64el platform

Basic information

I want to build osdetector-gradle-plugin for grpc-java locally. I get the source code from github. In the entire building process I encountered the following 2 errors:

The first one

when running the command "./gradlew install --info", I get the following info:

FAILURE: Build failed with an exception.
- What went wrong:
  Execution failed for task ':signArchives'.
  
  > Cannot perform signing task ':signArchives' because it has no configured signatory
- Try:
  Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.

BUILD FAILED

Total time: 44.037 secs
Stopped 0 compiler daemon(s).

then the second one

I commented the following line ---in file build.gradle line 61:
// sign configurations.archives
I try again it shows "Build Successfully"

Run test

But when I run "./gradlew test", I get the following error:

Starting process 'Gradle Test Executor 2'. Working directory: /usr/local/TenFlow/osdetector-gradle-plugin Command: /usr/lib/jvm/j2sdk-image/bin/java -Djava.security.manager=jarjar.org.gradle.process.internal.child.BootstrapSecurityManager -Dfile.encoding=UTF-8 -Duser.country=CN -Duser.language=zh -Duser.variant -ea -cp /root/.gradle/caches/2.3/workerMain/gradle-worker.jar jarjar.org.gradle.process.internal.launcher.GradleWorkerMain 'Gradle Test Executor 2'
Successfully started process 'Gradle Test Executor 2'
Gradle Test Executor 2 started executing tests.

com.google.gradle.osdetector.OsDetectorPluginTest > pluginAddsExtensionToProject STANDARD_OUT
    14:08:13.845 [Test worker] DEBUG o.g.i.n.f.s.FileSystemServices - Native-platform file system integration is not available. Continuing with fallback.
    14:08:13.888 [Test worker] DEBUG o.g.i.n.f.s.FileSystemServices - Using UnsupportedSymlink implementation.
    14:08:13.902 [Test worker] DEBUG o.g.i.n.f.s.FileSystemServices - Unable to load org.gradle.internal.nativeintegration.filesystem.jdk7.PosixJdk7FilePermissionHandler. Continuing with fallback org.gradle.internal.nativeintegration.filesystem.services.UnsupportedFilePermissions.
    14:08:16.765 [Test worker] DEBUG o.g.i.n.services.NativeServices - Native-platform process integration is not available. Continuing with fallback.
    14:08:20.494 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - ------------------------------------------------------------------------
    14:08:20.501 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - Detecting the operating system and CPU architecture
    14:08:20.502 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - ------------------------------------------------------------------------
    14:08:20.509 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - os.detected.name=linux
    14:08:20.510 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - os.detected.arch=unknown

com.google.gradle.osdetector.OsDetectorPluginTest > pluginAddsExtensionToProject FAILED
    kr.motd.maven.os.DetectionException: unknown os.arch: mips64el
        at kr.motd.maven.os.Detector.detect(Detector.java:73)
        at com.google.gradle.osdetector.OsDetector$Impl.<init>(OsDetector.java:117)
        at com.google.gradle.osdetector.OsDetector.getImpl(OsDetector.java:64)
        at com.google.gradle.osdetector.OsDetector.getOs(OsDetector.java:34)
        at com.google.gradle.osdetector.OsDetector_Decorated.getOs(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
        at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:60)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.getProperty(BeanDynamicObject.java:153)
        at org.gradle.api.internal.BeanDynamicObject.getProperty(BeanDynamicObject.java:107)
        at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:78)
        at com.google.gradle.osdetector.OsDetector_Decorated.getProperty(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:47)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
        at com.google.gradle.osdetector.OsDetectorPluginTest.pluginAddsExtensionToProject(OsDetectorPluginTest.groovy:31)

com.google.gradle.osdetector.OsDetectorPluginTest > setClassifierWithLikes STANDARD_OUT
    14:08:21.197 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - ------------------------------------------------------------------------
    14:08:21.200 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - Detecting the operating system and CPU architecture
    14:08:21.202 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - ------------------------------------------------------------------------
    14:08:21.207 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - os.detected.name=linux
    14:08:21.209 [Test worker] INFO  c.g.gradle.osdetector.OsDetector - os.detected.arch=unknown
Gradle Test Executor 2 finished executing tests.

Anyone can give me some tips to deal with this situation?

Revisit classifierWithLikes

Setting classifierWithLikes changes the content of the classifier. Because there is only one classifier instance in on JVM, if different components want different classifierWithLikes settings, they will run into each other. A real world example is in gRPC Java build, both tcnative artifact and protobuf-gradle-plugin are using classifier, while tcnative sets classifierWithLikes and protobuf-gradle-plugin doesn't.

We should either allow multiple classifiers in a JVM (by making it non-static), or remove the classifierWithLikes feature.

@ejona86

Faile build on PPC64LE system

I try to build a UTXO java client on PPC64LE system, but I failed at the osdetector part as followed:

r
09:15:18.829 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Mutating platformResolver using ComponentModelBasePlugin.Rules#platformResolver
09:15:18.829 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'platformResolver' to state Discovered.
09:15:19.097 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.check' from state Registered to Initialized
09:15:19.097 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Running model element 'tasks.check' rule action tasks.addPlaceholderAction(check)
09:15:19.097 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Mutating tasks.check using tasks.addPlaceholderAction(check)
09:15:19.097 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.check' to state Discovered.
09:15:19.098 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Running model element 'tasks.check' rule action tasks.addPlaceholderAction(check)
09:15:19.098 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Mutating tasks.check using tasks.addPlaceholderAction(check)
09:15:19.098 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.check' to state Created.
09:15:19.099 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.check' to state DefaultsApplied.
09:15:19.099 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Running model element 'tasks.check' rule action copyToTaskContainer
09:15:19.099 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Mutating tasks.check using copyToTaskContainer
09:15:19.099 [DEBUG] [org.gradle.model.internal.registry.DefaultModelRegistry] Transitioning model element 'tasks.check' to state Initialized.
09:15:19.257 [INFO] [com.google.gradle.osdetector.OsDetector] ------------------------------------------------------------------------
09:15:19.258 [INFO] [com.google.gradle.osdetector.OsDetector] Detecting the operating system and CPU architecture
09:15:19.258 [INFO] [com.google.gradle.osdetector.OsDetector] ------------------------------------------------------------------------
09:15:19.258 [INFO] [com.google.gradle.osdetector.OsDetector] os.detected.name=linux
09:15:19.259 [INFO] [com.google.gradle.osdetector.OsDetector] os.detected.arch=unknown
09:15:19.259 [INFO] [com.google.gradle.osdetector.OsDetector] os.detected.classifier=linux-unknown
09:15:19.261 [DEBUG] [org.gradle.configuration.project.BuildScriptProcessor] Timing: Running the build script took 2.063 secs
09:15:19.294 [ERROR] [org.gradle.BuildExceptionReporter]
09:15:19.294 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
09:15:19.294 [ERROR] [org.gradle.BuildExceptionReporter]
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter] * Where:
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter] Build file '/gpfs_bk/sysongyu/workspace/yu/obc-utxo-client-java/build.gradle' line: 12
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter]
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred evaluating root project 'obc-utxo-client-java'.
09:15:19.295 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to apply plugin [id 'osdetector']
09:15:19.296 [ERROR] [org.gradle.BuildExceptionReporter] > Could not create an instance of type com.google.gradle.osdetector.OsDetectorExtension_Decorated.
09:15:19.296 [ERROR] [org.gradle.BuildExceptionReporter]

Is there a work around for OsDector to work on PPC64LE system?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.