edwinRNDR / openrndr-library-template

A quick demonstration of turning https://github.com/openrndr/openrndr-template into a library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OPENRNDR library template

A project template to ease sharing your frequently used classes and extensions. You can publish the library

  • locally (to maven local) to use it in various OPENRNDR projects
  • online, thanks to jitpack, which takes care of building the library and making it available to other users.

Configuration

Before using this template set the following values:

build.gradle.kts

GitLab and other git hosts can also be used by jitpack. You can leave version unchanged.

group = "com.github.YOUR-USER-NAME"   
version = "main-SNAPSHOT"

settings.gradle.kts

rootProject.name = "openrndr-my-library"

This will be the library name when shared online.

Write some code

Place your library code, ideally organized in packages, inside src/main/kotlin/. A minimal library example:

// src/main/kotlin/Foo.kt
package com.myuser

class Foo {
    val bar = 12345
}

Publish

Locally

  • Run the publishToMavenLocal Gradle task.

Online

  • Push this repo including your library code into GitHub, Gitlab or similar.
  • Create a git Tag in the web interface for the version you want to distribute.

Using the library

In the project where you want to use your library you need to make two small changes to build.gradle.kts:

Locally

Use this option while developing your library and your programs.

  1. Add mavenLocal() to the repositories { ... } block.
  2. Inside the dependencies { ... } block, add a reference to your library matching the values you set earlier, for instance:
    implementation("com.github.YOUR-USER-NAME:openrndr-my-library:main-SNAPSHOT").
  3. Reload gradle and wait for indexing.
  4. The library code should be available in your project:
val foo = Foo()
println(foo.bar)

Online

Use this option to share your library with others.

  1. Add maven(url = "https://jitpack.io") to the repositories { ... } block.
  2. Inside the dependencies { ... } block, add a reference to your library matching the values you set earlier and the Tag you created, for instance implementation("com.github.YOUR-USER-NAME:openrndr-my-library:[TAG]").
  3. Reload gradle and wait for the library to be created in the jitpack server, then wait to download and index. It can take a few minutes on the first request and even fail to install the library. No worries: just reload Gradle after a few minutes (giving it time to build). Once the library is built downloading it is quick. That should be the experience for users of your library.
  4. The library code should be available in your project:
val foo = Foo()
println(foo.bar)

About

A quick demonstration of turning https://github.com/openrndr/openrndr-template into a library


Languages

Language:Kotlin 100.0%