Skip to content

Commit

Permalink
Figure out plugin publishing and update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Nov 21, 2023
1 parent 9ebb4d1 commit 265ae3b
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 33 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ jobs:
./gradlew build
- name: Publish
run: |
./gradlew publish closeAndReleaseSonatypeStagingRepository
./gradlew publish publishPlugins closeAndReleaseSonatypeStagingRepository
env:
IS_RELEASE: true
MAVEN_USER: github
MAVEN_PASSWORD: ${{ secrets.RELEASE_MAVEN_PASSWORD }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
SIGNING_KEY: ${{ secrets.GPG_KEY }}
SIGNING_PASSWORD: ${{ secrets.GPG_PASSWORD }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PLUGIN_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PLUGIN_SECRET }}
- run: |
git push
git push --tags
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ dependencies {

### Java

OpenSesame can be used with Java in several different ways, depending on your used case.

#### Javac Compiler Plugin

OpenSesame provides a javac plugin. Note that this will not work with eclipse's ecj compiler. To use, simply add the `opensesame-javac` dependency and specify the plugin in the compiler arguments. As there is almost no reason to have the compiler
plugin present at runtime, you will likely want to split it into its runtime and compile time components:

Expand All @@ -52,6 +56,24 @@ tasks.named('compileJava', JavaCompile).configure {
}
```

#### Gradle Plugin (WIP)

Using the gradle plugin, OpenSesame can insert a processing step into the compilation of a source set with ease. This
should have greater compatibility than the javac plugin. To use, simply apply the plugin, and then apply it to the source
set you want to process.

```gradle
plugins {
id 'dev.lukebemish.opensesame' version '<version>'
}
opensesame.apply(sourceSets.main)
dependencies {
implementation 'dev.lukebemish.opensesame:opensesame-core:<version>'
}
```

## Use

### General Use
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if (!System.getenv('PR_NUMBER') && !System.getenv('SNAPSHOT_MAVEN_URL')) {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Classpath
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectories
import org.gradle.api.tasks.TaskAction

Expand All @@ -22,7 +22,7 @@ import java.util.zip.ZipEntry
// Stole my own code from groovybundler... it works though
@CompileStatic
abstract class Bundler extends DefaultTask {
@Classpath
@InputFiles
abstract Property<Configuration> getBundleConfiguration()

@OutputDirectories
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package dev.lukebemish.opensesame.convention
import groovy.json.JsonBuilder
import groovy.transform.CompileStatic
import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.OutputDirectories
import org.gradle.api.tasks.TaskAction

Expand All @@ -20,6 +22,8 @@ abstract class FabricModJson extends DefaultTask {
abstract Property<String> getProjectName()
@Input
abstract Property<String> getProjectVersion()
@InputFiles
abstract Property<Configuration> getBundledDependencies()

@TaskAction
void generateFabricModJson() {
Expand All @@ -29,9 +33,9 @@ abstract class FabricModJson extends DefaultTask {
'id': modid,
'version': projectName.get(),
'name': projectName.get(),
'custom': [
'opensesame.bundler:generated': true,
]
'jars': getBundledDependencies().get().files.collect {
['file': "META-INF/jarjar/${it.name}" as String]
},
]
getOutputDirectory().get().file("fabric.mod.json").asFile.withWriter { writer ->
writer.write(new JsonBuilder(fmj).toPrettyString())
Expand Down
8 changes: 4 additions & 4 deletions buildSrc/src/main/groovy/opensesame.conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class OpenSesameConventionExtension {
def pomShared(MavenPom it, String name) {
it.name = "OpenSesame - $name".toString()
it.packaging = 'jar'
it.url = 'https://github.com/lukebemish/OpenSesame'
it.url = 'https://github.com/lukebemishprojects/OpenSesame'
it.inceptionYear = '2023'

it.licenses {
Expand All @@ -181,9 +181,9 @@ class OpenSesameConventionExtension {
}
}
it.scm {
connection='scm:git:git://github.com/lukebemish/OpenSesame.git'
developerConnection='scm:git:ssh://github.com/lukebemish/OpenSesame.git'
url='https://github.com/lukebemish/OpenSesame'
connection='scm:git:git://github.com/lukebemishprojects/OpenSesame.git'
developerConnection='scm:git:ssh://github.com/lukebemishprojects/OpenSesame.git'
url='https://github.com/lukebemishprojects/OpenSesame'
}
}
}
Expand Down
1 change: 1 addition & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tasks.register('generateFMJ', FabricModJson) {
projectGroup = project.group
projectVersion = project.version
projectName = project.name
bundledDependencies = configurations.bundle
outputDirectory = layout.buildDirectory.dir("fabricModJson")
}

Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ asm = "9.4"

managedversioning = "1.1.0"
nexuspublish = "1.3.0"
gradlepublish = "1.1.0"

fabric_loom = "1.4.4"
fabric_loader = "0.14.9"
Expand All @@ -31,4 +32,5 @@ fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_l
[plugins]

managedversioning = { id = "dev.lukebemish.managedversioning", version.ref = "managedversioning" }
nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexuspublish" }
nexuspublish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexuspublish" }
gradlepublish = { id = "com.gradle.plugin-publish", version.ref = "gradlepublish" }
54 changes: 34 additions & 20 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java-gradle-plugin'
id 'com.gradle.plugin-publish' version '1.1.0'
alias libs.plugins.gradlepublish
}

java.toolchain.languageVersion.set JavaLanguageVersion.of(17)
Expand All @@ -17,7 +17,6 @@ repositories {
}

java.withSourcesJar()
java.withJavadocJar()

dependencies {
compileOnly libs.jetbrains.annotations
Expand All @@ -36,8 +35,8 @@ dependencies {
}

gradlePlugin {
website = 'https://github.com/lukebemish/OpenSesame'
vcsUrl = 'https://github.com/lukebemish/OpenSesame.git'
website = 'https://github.com/lukebemishprojects/OpenSesame'
vcsUrl = 'https://github.com/lukebemishprojects/OpenSesame.git'

plugins {
openSesame {
Expand All @@ -54,26 +53,41 @@ processResources {
from rootProject.file('LICENSE')
}

if (System.getenv('PR_NUMBER')) {
publishing {
repositories {
maven {
name = 'LocalMaven'
url = rootProject.layout.buildDirectory.dir('repo')
if (System.getenv('GRADLE_PLUGIN_KEY')) {
ext['gradle.publish.key'] = System.getenv('GRADLE_PLUGIN_KEY')
ext['gradle.publish.secret'] = System.getenv('GRADLE_PLUGIN_SECRET')
}

afterEvaluate {
publishing.repositories.clear()

if (System.getenv('PR_NUMBER')) {
publishing {
repositories {
maven {
name = 'LocalMaven'
url = rootProject.layout.buildDirectory.dir('repo')
}
}
}
}
} else if (System.getenv('SNAPSHOT_MAVEN_URL')) {
publishing {
repositories {
maven {
name = 'PersonalMaven'
url = uri(System.getenv('SNAPSHOT_MAVEN_URL'))
credentials {
username = System.getenv('MAVEN_USER')
password = System.getenv('MAVEN_PASSWORD')
} else if (System.getenv('SNAPSHOT_MAVEN_URL')) {
publishing {
repositories {
maven {
name = 'PersonalMaven'
url = uri(System.getenv('SNAPSHOT_MAVEN_URL'))
credentials {
username = System.getenv('MAVEN_USER')
password = System.getenv('MAVEN_PASSWORD')
}
}
}
}
} else {
publishing {
repositories {
gradlePluginPortal()
}
}
}
}

0 comments on commit 265ae3b

Please sign in to comment.