Skip to content

Commit 13a1900

Browse files
committed
add docs
1 parent c5c80b2 commit 13a1900

File tree

2 files changed

+94
-3
lines changed

2 files changed

+94
-3
lines changed

README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,92 @@
11
# ExpectPlatform
2+
3+
This is a simple project that implements `@ExpectPlatform` and `@PlatformOnly` in a non-specific way.
4+
5+
## Usage
6+
7+
to use this project, you can add the following to your `settings.gradle` file:
8+
```gradle
9+
pluginManagement {
10+
repositories {
11+
mavenLocal()
12+
maven {
13+
url = "https://maven.wagyourtail.xyz/releases"
14+
}
15+
maven {
16+
url = "https://maven.wagyourtail.xyz/snapshots"
17+
}
18+
mavenCentral()
19+
gradlePluginPortal()
20+
}
21+
}
22+
```
23+
24+
and then add the plugin to your `build.gradle` file:
25+
```gradle
26+
plugins {
27+
id 'xyz.wagyourtail.unimined.expect-platform' version '1.0.3'
28+
}
29+
```
30+
31+
you can add the annotations to be accessible with
32+
```gradle
33+
dependencies {
34+
implementation(expectPlatform.annotationsDep)
35+
// or
36+
implementation("xyz.wagyourtail.unimined:expect-platform-annotations:${expectPlatform.version}")
37+
}
38+
```
39+
40+
to then apply the annotations in a subproject or other module, you can either do:
41+
42+
```gradle
43+
tasks.create("expectPlatformOutput") {
44+
group = "unimined"
45+
platformName = platformName
46+
inputCollection = rootProject.sourceSets["main"].output
47+
}
48+
49+
dependencies {
50+
common(expectPlatformOutput.outputCollection)
51+
}
52+
```
53+
54+
or, you can apply the agent to a JavaExec and create a task to make the final jar:
55+
56+
```gradle
57+
tasks.withType(JavaExec) {
58+
expectPlatform.insertAgent(it, platformName)
59+
}
60+
61+
tasks.create("PlatformJar", xyz.wagyourtail.unimined.expect.ExpectPlatformJar) {
62+
group = "unimined"
63+
dependsOn("jar")
64+
65+
inputFiles = tasks.jar.outputs.files
66+
platformName = platformName
67+
}
68+
69+
```
70+
71+
if you need the agent on a runner that isn't implementing JavaExecSpec (ie, the one in unimined)
72+
check [the implementation](src/main/kotlin/xyz/wagyourtail/unimined/expect/ExpectPlatformExtension.kt#L69) for how it actually applies the agent to a JavaExec task.
73+
74+
### Environment
75+
76+
This plugin also provides an `@Environment` annotation, but doesn't hook it up.
77+
to do so, you can use the following code snippets (as either setting in the task, or the third arg to the agent):
78+
```gradle
79+
// neoforge
80+
remap = [
81+
"xyz/wagyourtail/unimined/expect/annotation/Environment": "net/neoforged/api/distmarker/OnlyIn",
82+
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType": "net/neoforged/api/distmarker/Dist",
83+
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType.SERVER": "DEDICATED_SERVER",
84+
]
85+
// fabric
86+
remap = [
87+
"xyz/wagyourtail/unimined/expect/annotation/Environment": "net/fabricmc/api/Environment",
88+
"xyz/wagyourtail/unimined/expect/annotation/Environment\$EnvType": "net/fabricmc/api/EnvType",
89+
]
90+
```
91+
92+
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.

src/main/kotlin/xyz/wagyourtail/unimined/expect/ExpectPlatformExtension.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import groovy.lang.DelegatesTo
55
import org.gradle.api.Project
66
import org.gradle.api.artifacts.Configuration
77
import org.gradle.api.attributes.Attribute
8-
import org.gradle.api.tasks.Internal
98
import org.gradle.process.JavaExecSpec
9+
import org.jetbrains.annotations.VisibleForTesting
1010
import xyz.wagyourtail.unimined.expect.transform.ExpectPlatformParams
1111
import xyz.wagyourtail.unimined.expect.transform.ExpectPlatformTransform
1212

1313
abstract class ExpectPlatformExtension(val project: Project) {
14-
@get:Internal
15-
@set:Internal
14+
15+
@set:VisibleForTesting
1616
var version = ExpectPlatformExtension::class.java.`package`.implementationVersion ?: "1.0.0-SNAPSHOT"
1717

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

0 commit comments

Comments
 (0)