这是indexloc提供的服务,不要输入任何密码
Skip to content

ffung/jython-gradle-plugin

Repository files navigation

Jython Gradle Plugin

jython gradle plugin

This plugin will scan and adapt your source files to include a provided header, e.g. a LICENSE file. By default it will scan every source set and report warnings. It will also create format tasks, which will properly format and apply the specified header. A bulk of the logic comes from the maven-license-plugin.

This plugin will also report on the licenses of your dependencies.

Usage

The jython-gradle-plugin will be published to http://bintray.com and will be available through the Gradle plugin exchange. This means that there are a few different usage scenarios listed below.

Gradle 2.1 and above

In your build.gradle file add:

plugins {
    id "com.github.hierynomus.jython" version "0.3.0"
}

Gradle 1.x/2.0

In your build.gradle file add:

    buildscript {
        repositories {
            jcenter()
        }

        dependencies {
            classpath 'com.hierynomus.gradle.plugins:jython-gradle-plugin:0.3.0'
        }
    }

Example

The following example will download the boto3 library from pypi.python.org and bundle it in your Jar file.

plugins {
    id "java"
    id "com.github.hierynomus.jython" version "0.3.0"
}

dependencies {
  jython ":boto3:1.1.3"
}

Configuration

By default the following two repository-patterns have been defined for the plugin:

The pipy repository pattern triggers special behavior. A REST call to https://pypi.python.org/pypi/${dep.name}/json is made and the URL for the source release for that version is retrieved from the response.

These can be overridden or extended using the jython extension. For instance:

jython {
  sourceRepositories += `http://my.local.repo/${dep.name}/${dep.version}/${dep.name}-${dep.version}.tar.gz
}

Non-default libraries/modules

If a python module name differs from the artifact name.

In some cases, the python module name is not the same as the artifact name. In order to overcome this, you can use the classifier of the dependency to set the correct module name used for extraction. For instance:

dependencies {
  jython "jmespath:jmespath.py:0.7.1:jmespath"
  jython ":python-dateutil:2.4.2:dateutil"
}

If you only need to include specific file(s) from the module

In some cases, the python script(s) are not bundled in a python module directory, but rather in the root. In these cases you can configure the plugin with the following dependency:

dependencies {
  jython(":six:1.9.0") {
    artifact {
      name = "six"
      extension = "py"
    }
  }
}

This will only add the six.py file from the downloaded module.

Changelog

v0.4.0 (2015-10-07)

  • Converted download code from Apache HTTP to Groovy HTTP-Builder (Fixes #7)

v0.3.0 (2015-10-07)

  • Added support for .zip python modules

v0.2.0 (2015-09-14)

  • Added support for extracting a specific artifact from the dependency

v0.1.0 (2015-09-11)

  • Initial version supporting pypi and github library locations

About

Allows to download Jython/Python modules from pypi

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Groovy 100.0%