Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jun 7, 2024
1 parent c5c80b2 commit 13a1900
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 3 deletions.
91 changes: 91 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,92 @@
# ExpectPlatform

This is a simple project that implements `@ExpectPlatform` and `@PlatformOnly` in a non-specific way.

## Usage

to use this project, you can add the following to your `settings.gradle` file:
```gradle
pluginManagement {
repositories {
mavenLocal()
maven {
url = "https://maven.wagyourtail.xyz/releases"
}
maven {
url = "https://maven.wagyourtail.xyz/snapshots"
}
mavenCentral()
gradlePluginPortal()
}
}
```

and then add the plugin to your `build.gradle` file:
```gradle
plugins {
id 'xyz.wagyourtail.unimined.expect-platform' version '1.0.3'
}
```

you can add the annotations to be accessible with
```gradle
dependencies {
implementation(expectPlatform.annotationsDep)
// or
implementation("xyz.wagyourtail.unimined:expect-platform-annotations:${expectPlatform.version}")
}
```

to then apply the annotations in a subproject or other module, you can either do:

```gradle
tasks.create("expectPlatformOutput") {
group = "unimined"
platformName = platformName
inputCollection = rootProject.sourceSets["main"].output
}
dependencies {
common(expectPlatformOutput.outputCollection)
}
```

or, you can apply the agent to a JavaExec and create a task to make the final jar:

```gradle
tasks.withType(JavaExec) {
expectPlatform.insertAgent(it, platformName)
}
tasks.create("PlatformJar", xyz.wagyourtail.unimined.expect.ExpectPlatformJar) {
group = "unimined"
dependsOn("jar")
inputFiles = tasks.jar.outputs.files
platformName = platformName
}
```

if you need the agent on a runner that isn't implementing JavaExecSpec (ie, the one in unimined)
check [the implementation](src/main/kotlin/xyz/wagyourtail/unimined/expect/ExpectPlatformExtension.kt#L69) for how it actually applies the agent to a JavaExec task.

### Environment

This plugin also provides an `@Environment` annotation, but doesn't hook it up.
to do so, you can use the following code snippets (as either setting in the task, or the third arg to the agent):
```gradle
// neoforge
remap = [
"xyz/wagyourtail/unimined/expect/annotation/Environment": "net/neoforged/api/distmarker/OnlyIn",
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType": "net/neoforged/api/distmarker/Dist",
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType.SERVER": "DEDICATED_SERVER",
]
// fabric
remap = [
"xyz/wagyourtail/unimined/expect/annotation/Environment": "net/fabricmc/api/Environment",
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType": "net/fabricmc/api/EnvType",
]
```

Do note that while this plugin contains `EnvType.COMBINED`, it is not present in fabric or neoforge, so it is not recommended to use it.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import groovy.lang.DelegatesTo
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.attributes.Attribute
import org.gradle.api.tasks.Internal
import org.gradle.process.JavaExecSpec
import org.jetbrains.annotations.VisibleForTesting
import xyz.wagyourtail.unimined.expect.transform.ExpectPlatformParams
import xyz.wagyourtail.unimined.expect.transform.ExpectPlatformTransform

abstract class ExpectPlatformExtension(val project: Project) {
@get:Internal
@set:Internal

@set:VisibleForTesting
var version = ExpectPlatformExtension::class.java.`package`.implementationVersion ?: "1.0.0-SNAPSHOT"

val annotationsDep by lazy { "xyz.wagyourtail.unimined.expect-platform:expect-platform-annotations:$version" }
Expand Down

0 comments on commit 13a1900

Please sign in to comment.