pony-gradle-plugin

A Gradle Plugin for the Pony programming language

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.athaydes.pony.gradle
ArtifactId

ArtifactId

pony-gradle-plugin
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

jar
Description

Description

pony-gradle-plugin
A Gradle Plugin for the Pony programming language
Project URL

Project URL

https://github.com/renatoathaydes/pony-gradle-plugin
Source Code Management

Source Code Management

https://github.com/renatoathaydes/pony-gradle-plugin

Download pony-gradle-plugin

How to add to project

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

Dependencies

test (1)

Group / Artifact Type Version
org.spockframework : spock-core jar 1.0-groovy-2.4

Project Modules

There are no modules declared in this project.

Pony Gradle Plugin

๐Ÿด A Gradle Plugin to build Pony projects.

Features

  • compile Pony sources.
  • resolve dependencies using bundle.json - compatible with pony-stable.
  • resolve transitive dependencies (if the dependencies have a bundle.json file).

Getting started

Run the following commands to create a Pony project with Gradle support:

  • create and enter your new project directory.
mkdir my-project && cd my-project
  • create the Gradle build file.
echo '
plugins {
  id "com.athaydes.pony" version "0.2.0"
}
' > build.gradle
  • create a Pony package with a Main actor.
mkdir main
echo '
actor Main
    new create(env: Env) =>
        env.out.print("Hello world!")
' > main/main.pony
  • compile with Gradle.
gradle compile
  • run the generated binary.
build/main

The following sections explain how this all works in detail.

Build files

To enable Gradle support, a basic build.gradle file must be supplied to apply this plugin. Dependencies are declared separately (to be compatible with pony-stable) in the bundle.json file.

build.gradle - the Gradle build file.

Simplest possible example without any configuration (see below for defaults):

plugins {
  id "com.athaydes.pony" version "0.2.0"
}

The above is all you need, but you may configure the build using the pony block:

plugins {
  id "com.athaydes.pony" version "0.2.0"
}

pony {
  packageName = 'hello'
  docs = true
}

Configuration options

Option Type Default Description
packageName String main name of the package to compile.
testPackage String test name of the test package to compile and run.
docs Boolean false whether to generate docs.
debug Boolean false Don't optimise the output.
library Boolean false Generate a C-API compatible static library.
strip Boolean false Strip debug info.
runtimebc Boolean false Compile with the LLVM bitcode file for the runtime.
pic Boolean false Compile using position independent code.
compileOptions List [] Extra compiler options to use when compiling.
testOptions List [] Extra compiler options to use when compiling and running tests.

To get started, see the Hello World sample.

See the pony-configured sample for a build file that uses all options.

bundle.json - pony-stable dependencies file.

Example:

{
  "name": "my-project",
  "version": "2.3.4",
  "deps": [
    { "type": "github", "repo": "jemc/pony-inspect", "version": "1.0.1" },
    { "type": "github", "repo": "other/dep" },
    { "type": "local", "local-path": "../my-other-dep" }
  ]
}

Everything in the json file is optional. Unrecognized fields are ignored.

Dependency types

The currently supported dependency types are the following:

GitHub

GitHub dependencies are downloaded using the GitHub API, so other Git repositories are not currently supported.

GitHub dependencies have the following fields:

  • type (mandatory): must be github.
  • repo (mandatory): <github-user>/<repository-name>.
  • version (optional): tag/branch/commit

If version is not given, the latest tag will be used, or if there's no tags, the main branch (usually master).

See the pony-basic sample for an example.

Local

Local dependencies are simple Pony projects that are located in the local file system.

They are declared using the following fields:

  • type (mandatory): must be local.
  • local-path (mandatory): the path, relative to the root of this project, to the dependency project.

See the pony-multi-modules sample for an example.

Tasks

The following tasks are added by this plugin:

  • cleanPony: deletes all artifacts created by previous builds.
  • resolvePonyDependencies: resolves the project dependencies.
  • unpackPonyDependencies: unpacks the dependencies archives.
  • compilePony: compiles Pony sources and dependencies.
  • testPony: compiles Pony sources and tests, then runs the test package.

Normally, all you need to do to build your project is run compilePony, or just compile:

gradle compile

The other tasks will be run automatically if necessary.

You can run only the task you want as well, for example:

gradle resolve

The above will resolve all dependencies. If any dependencies need to be downloaded, they will be, so that transitive dependencies can be also resolved.

To compile both sources and test sources, then run tests, simply run the test task:

gradle test

Build layout

Everything the Pony plugin creates goes into Gradle's project.buildDir, which is build by default.

Sources should go into the packageName directory, as in any Pony project.

For a project called pony-basic, the layout would look something like this after built:

โ”œโ”€โ”€ ext-libs          # external libraries sources
โ”‚   โ”œโ”€โ”€ unpacked      # unpacked libraries
โ”‚   โ”‚   โ”œโ”€โ”€ jemc-pony-inspect-03a65d4
โ”‚   โ”‚   โ”‚   ...
โ”‚   โ”‚   โ”œโ”€โ”€ jemc-pony-sodium-d293cdb
โ”‚   โ”‚   โ”‚   ...
โ”‚   โ”‚   โ””โ”€โ”€ jemc-pony-zmq-6e9157e
โ”‚   โ”‚       ...
โ”‚   โ””โ”€โ”€ zips          # packaged libraries (not necessary to compile)
โ”‚       โ”œโ”€โ”€ jemc-pony-inspect.zip
โ”‚       โ”œโ”€โ”€ jemc-pony-sodium.zip
โ”‚       โ””โ”€โ”€ jemc-pony-zmq.zip
โ”œโ”€โ”€ build                 # generated by the Pony plugin
โ”‚   โ”œโ”€โ”€ pony-basic        # generated by ponyc
โ”‚   โ””โ”€โ”€ pony-basic.dSYM
โ”‚       โ””โ”€โ”€ Contents
โ”‚           โ”œโ”€โ”€ Info.plist
โ”‚           โ””โ”€โ”€ Resources
โ”‚               โ””โ”€โ”€ DWARF
โ”‚                   โ””โ”€โ”€ pony-basic
โ”œโ”€โ”€ build.gradle          # Gradle build file
โ”œโ”€โ”€ bundle.json           # dependencies file
โ””โ”€โ”€ pony-basic            # source directory
    โ””โ”€โ”€ Main.pony

20 directories, 79 files

Versions

Version
0.2.0
0.1.0