Skip to content

Commit

Permalink
Merge pull request #22 from Diluv/1.4.x
Browse files Browse the repository at this point in the history
1.4.x Release
  • Loading branch information
Darkhax authored Jan 2, 2021
2 parents 059a250 + b992660 commit 7653ddf
Show file tree
Hide file tree
Showing 63 changed files with 2,171 additions and 321 deletions.
83 changes: 46 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
# [Diluv-Gradle](https://plugins.gradle.org/plugin/com.diluv.diluvgradle)
A Gradle plugin for uploading build artifacts directly to Diluv.
# [Diluv-Gradle](https://plugins.gradle.org/plugin/com.diluv.diluvgradle) ![Latest Version](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/diluv/diluvgradle/com.diluv.diluvgradle.gradle.plugin/maven-metadata.xml.svg?colorB=007ec6&label=Latest%20Version)
A Gradle plugin for uploading Gradle build artifacts directly to Diluv.

## Features

- Upload build artifacts to Diluv directly.
- Auto-detect game version from environmental context clues.
- Auto-detect supported mod loaders from environmental context clues.
- Lots of configuration options and scripting potential.

## Usage Guide
To use this plugin you must add it to your build script. This can be done using the plugins DSL or added to the classpath directly for legacy scripts.

**Plugin DSL**
```gradle
plugins {
id "com.diluv.diluvgradle" version "1.2.2"
id "com.diluv.diluvgradle" version "1.4.0"
}
```

Expand All @@ -32,43 +39,44 @@ import com.diluv.diluvgradle.TaskDiluvUpload
task publishDiluv (type: TaskDiluvUpload){
token = 'a7104dd8-f43a-4468-b5cd-b6ed3394916d' // Use an environment property!
projectId = 123456
projectVersion = '1.0.0'
uploadFile = jar // This is the java jar task
addGameVersion('1.16.4')
// This token is used to authenticate with Diluv. It should be handled with the same
// sensitivity and security as a password. This means you should never share this token
// or upload it to a public location such as GitHub. These are commonly stored as secret
// environmental variables.
token = findProperty('diluv_token');
// This tells Diluv what project you are uploading the file to. You can find the ID for
// any project on the Diluv Project Page. This is not considered secret or sensitive.
projectId = findProperty('diluv_project');
// Tells DiluvGradle what file to upload. This can be a Java file, a path to a file, or
// certain tasks which produce files such as any AbstractArchiveTask.
uploadFile = jar;
}
```

### Available Properties

| Property | Required | Description |
|----------------------------------|----------|-------------------------------------------------------------------------------------|
| apiURL | false | The API endpoint URL to use for uploading files. Defaults to official Diluv API. |
| token | true | A valid API token for the Diluv API. |
| projectId | true | The ID of the project to upload to. |
| projectVersion | true | The version of the file. Please use semantic versioning. |
| changelog | false | The changelog for the file. Allows Markdown formatting. |
| uploadFile | true | The file to upload. Can be an actual file or a file task. |
| releaseType | false | The release status of the file. Defaults to "alpha". |
| classifier | false | The type of file being uploaded. Defaults to binary. |
| failSilently | false | When true an upload failure will not fail your build. |
| addGameVersion(version) | true | Adds a game version that this file supports. At least one is needed. |
| addDependency(projectId) | false | Marks a project as a required dependency. |
| addOptionalDependency(projectId) | false | Marks a project as an optional/soft dependency. |
| addIncompatibility(projectId) | false | Marks a project as being incompatible with this file. |
| addRelation(projectId, type) | false | Adds a project relationship to the file. Only some relationship types are accepted. |
| addLoader(loader) | false | Allows supported mod loaders to be specified for the file. |

**Note:** In some scenarios the `gameVersion` property can be detected automatically. For example the ForgeGradle and LoomGradle environments. For best results you should set this property manually.

### Additional Properties

| Name | Description |
|-----------------------|-----------------------------------------------------------------------------------------------------|
| uploadInfo | The response from the API server. Only present after upload is completed successfully. |
| errorInfo | The response from the API server. Only present after an upload fails. |
| wasUploadSuccessful() | Checks if the upload was successful or not. Should be used before accessing uploadInfo or errorInfo |
| Name | Type | Description |
|----------------------------------|--------|----------------------------------------------------------------------------------------------------------------------------------|
| apiUrl | Field | The URL for the Diluv REST API to use. This is primarily used to debug with locally hosted instances of the API. |
| projectId | Field | The ID of the project to upload your file to. This is a required property to set. |
| token | Field | The authorization token used to verify your identity with the Diluv API. This is a required property to set. |
| uploadFile | Field | The file to upload. This can be a file instance, path to a file, or some tasks that produce a file such as "jar". |
| failSilently | Field | Enabling this option will allow the DiluvGradle plugin to fail without causing the entire build to fail. |
| ignoreSemVer | Field | Enabling this option will disable local semantic versioning checks. This will not cause server-side checks to be disabled. |
| detectLoaders | Field | Disabling this will prevent the auto detection of mod loaders. |
| addGameVersion(version) | Method | Adds a compatible game version to the list of versions supported by the file. |
| setVersion(version) | Method | Sets the version of the file itself. By default this will pull from the project.version property. |
| setChangelog(changelog) | Method | Sets the change log for the file. This can be a string or a plaintext file containing the changelog info. |
| setReleaseType(type) | Method | Sets the release type for the project. Accepted values are "alpha", "beta", and "release". |
| addDependency(projectId) | Method | Marks another Diluv project as a required dependency for this file. |
| addOptionalDependency(projectId) | Method | Marks another Diluv project as being recommended or having additional functionality with this file. |
| addIncompatibility(projectId) | Method | Marks another Diluv project as being incompatible with this file. |
| addLoader(loader) | Method | Marks a mod loader as being compatible with the file. Such as "forge" or "fabric". |
| wasUploadSuccessful() | Method | Returns true if the file was successfully uploaded. If false is returned the upload failed or the file hasn't been uploaded yet. |
| getUploadInfo() | Method | Returns an object containing various API data about the file that was uploaded. If called too early an exception will be raised. |
| getErrorInfo() | Method | Returns an object containing the error message from the API. If called too early an exception will be raised. |

#### Upload Info

Expand Down Expand Up @@ -118,8 +126,6 @@ task publishDiluv (type: TaskDiluvUpload){
| avatarURL | String | A URL that points to their profile avatar. |
| createdAt | Long | The timestamp for when the user joined Diluv. |

#### UserInfo

## Development Information
This section contains information useful to those working on the plugin directly or creating their own custom versions of our plugin. If you want to just use DiluvGradle in your build pipeline you will not need to know or understand any of this.

Expand All @@ -143,3 +149,6 @@ buildscript {
}
}
```

### Examples
Many example projects can be found in the [examples](https://github.com/Diluv/Diluv-Gradle/tree/main/examples) section of this repo. These projects provide a great environment for debugging the plugin and testing out new changes.
4 changes: 4 additions & 0 deletions examples/local_minecraft_fabric_loom_gradle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
####################
## Fabric/Minecraft
####################
/run
18 changes: 18 additions & 0 deletions examples/local_minecraft_fabric_loom_gradle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Minecraft Fabric Example
This example is used to debug Diluv's integration with Fabric's Loom Gradle plugin. This example has been configured to connect to a locally hosted instance of the Diluv API that has been supplied with our mock database.

## Usage Guide
1. Make sure the local DiluvGradle plugin has been built. This is done by running `./gradlew clean build` in the root directory of this project repo.
2. Make sure the local API is running and that the `gradle.properties` file reflects your local API and database.
3. Run `./gradlew clean build publishDiluv` in the example directory.

## ⚠️Security Note⚠️
Remember to never publish your auth token in a public environment such as Github. Auth tokens are private information and should be treated with the same level of security as an account password. When using with a build server like Jenkins or GitHub actions the auth token should be injected as a build secret.

## Verifying Integration
To verify that integration with Loom was successful run the `./gradlew build publishDiluv -d` command. then look for the following things in your log.

1. The build was successful.
2. The log contains `[DiluvGradle] Applying loader fabric because pluing fabric-loom was found.`
3. The log contains `[DiluvGradle] Diluv Response Code: 200`.
4. The file was uploaded to the expected Diluv project.
100 changes: 100 additions & 0 deletions examples/local_minecraft_fabric_loom_gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
buildscript {

dependencies {

classpath files { file('../../build/libs').listFiles()}
classpath group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.2'
classpath group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.2'
classpath group: 'com.google.code.gson', name: 'gson', version: '2.6.2'
}
}

plugins {

id 'fabric-loom' version '0.5-SNAPSHOT'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = "${project.mod_version}.${Math.abs(new Random().nextInt())}"

dependencies {

minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"

modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
}

processResources {

inputs.property "version", project.version

filesMatching("fabric.mod.json") {

expand "version": project.version
}
}

java {

withSourcesJar()
}

// Diluv Publishing
import com.diluv.diluvgradle.TaskDiluvUpload

task publishDiluv (type: TaskDiluvUpload) {

// ======================
// === REQUIRED STUFF ===
// ======================

// This token is used to authenticate with Diluv. It should be handled with the same
// sensitivity and security as a password. This means you should never share this token
// or upload it to a public location such as GitHub. These are commonly stored as secret
// environmental variables.
token = findProperty('diluv_token');

// This tells Diluv what project you are uploading the file to. You can find the ID for
// any project on the Diluv Project Page. This is not considered secret or sensitive.
projectId = findProperty('diluv_project');

// Tells DiluvGradle what file to upload. This can be a Java file, a path to a file, or
// certain tasks which produce files such as any AbstractArchiveTask.
uploadFile = jar;

// ======================
// === OPTIONAL STUFF ===
// ======================

// Specifies the version of the file. This is auto-detected from Gradle's project.version
// property if you do not specify this yourself.
// setVersion('1.3.22');

// Specifies game versions that the file is compatible with. DiluvGradle can auto-detect
// detect this from ForgeGradle if you don't specify at least one version.
// addGameVersion('1.12.2');

// Specifies a changelog for your file. This can be hard coded or generated at build time.
// setChangelog('The changelog string for your file.');

// Relations between your file and other files on Diluv can be defined like this.
// addDependency(projectId); - A project that your file requires.
// addOptionalDependency(projectId); - A project that your file has additional support for.
// addIncompatibility(projectId); - A project that your file is not compatible with.

// Specifies a mod loader that your file is compatible with. When ForgeGradle is present
// the loader 'forge' will be added by default. When Loom is present 'fabric' is added.
// addLoader('loadername');

// Defines the type of release this file is. This is 'alpha' by default.
// Accepts 'alpha', 'beta', and 'release'.
// setReleaseType('beta');

// Changes the API URL that DiluvGradle uses to authenticate and upload the file to. This
// is primarily intended for debugging.
apiURL = findProperty('diluv_api');
}
15 changes: 15 additions & 0 deletions examples/local_minecraft_fabric_loom_gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.6
loader_version=0.10.6+build.214

# Mod Properties
mod_version = 1.0
archives_base_name = diluv-fabric-test

# Diluv Properties
diluv_token=8dfa96ba-44b0-4eb0-930a-fca183e73ec8
diluv_project=1
diluv_api=http://127.0.0.1:4567
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
Loading

0 comments on commit 7653ddf

Please sign in to comment.