mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-24 20:07:54 +01:00
Add common publishing
This commit is contained in:
parent
b9490fe11a
commit
f15501dac8
6 changed files with 167 additions and 21 deletions
|
@ -19,10 +19,14 @@ repositories {
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
simplePlugin {
|
platformPlugin {
|
||||||
id = 'flywheel.platform'
|
id = 'flywheel.platform'
|
||||||
implementationClass = 'com.jozufozu.gradle.PlatformPlugin'
|
implementationClass = 'com.jozufozu.gradle.PlatformPlugin'
|
||||||
}
|
}
|
||||||
|
outgoingConfigurationPlugin {
|
||||||
|
id = 'flywheel.outgoing-configuration'
|
||||||
|
implementationClass = 'com.jozufozu.gradle.OutgoingConfigurationPlugin'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.jozufozu.gradle
|
||||||
|
|
||||||
|
import net.fabricmc.loom.task.RemapJarTask
|
||||||
|
import net.fabricmc.loom.task.RemapSourcesJarTask
|
||||||
|
import org.gradle.api.tasks.TaskProvider
|
||||||
|
import org.gradle.api.tasks.bundling.Jar
|
||||||
|
|
||||||
|
class JarTaskSet {
|
||||||
|
TaskProvider<Jar> jar
|
||||||
|
TaskProvider<RemapJarTask> remapJar
|
||||||
|
TaskProvider<Jar> sources
|
||||||
|
TaskProvider<RemapSourcesJarTask> remapSources
|
||||||
|
TaskProvider<Jar> javadocJar
|
||||||
|
|
||||||
|
JarTaskSet(TaskProvider<Jar> jar, TaskProvider<RemapJarTask> remapJar, TaskProvider<Jar> sources, TaskProvider<RemapSourcesJarTask> remapSources, TaskProvider<Jar> javadocJar) {
|
||||||
|
this.jar = jar
|
||||||
|
this.remapJar = remapJar
|
||||||
|
this.sources = sources
|
||||||
|
this.remapSources = remapSources
|
||||||
|
this.javadocJar = javadocJar
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.jozufozu.gradle
|
||||||
|
|
||||||
|
import net.fabricmc.loom.task.RemapJarTask
|
||||||
|
import net.fabricmc.loom.task.RemapSourcesJarTask
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.artifacts.ConfigurationContainer
|
||||||
|
import org.gradle.api.artifacts.dsl.ArtifactHandler
|
||||||
|
import org.gradle.api.tasks.SourceSet
|
||||||
|
import org.gradle.api.tasks.SourceSetContainer
|
||||||
|
import org.gradle.api.tasks.TaskContainer
|
||||||
|
import org.gradle.api.tasks.bundling.Jar
|
||||||
|
import org.gradle.api.tasks.javadoc.Javadoc
|
||||||
|
|
||||||
|
class OutgoingConfigurationPlugin implements Plugin<Project> {
|
||||||
|
@Override
|
||||||
|
void apply(Project project) {
|
||||||
|
project.extensions.create("outgoing", Extension, project)
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Extension {
|
||||||
|
private final Project project
|
||||||
|
private final SourceSetContainer sourceSets
|
||||||
|
private final ConfigurationContainer configurations
|
||||||
|
private final TaskContainer tasks
|
||||||
|
private final ArtifactHandler artifacts
|
||||||
|
|
||||||
|
Extension(Project project) {
|
||||||
|
this.project = project
|
||||||
|
this.sourceSets = project.getExtensions().getByType(SourceSetContainer)
|
||||||
|
this.configurations = project.configurations
|
||||||
|
this.tasks = project.tasks
|
||||||
|
this.artifacts = project.artifacts
|
||||||
|
}
|
||||||
|
|
||||||
|
JarTaskSet createJarAndOutgoingConfiguration(String name) {
|
||||||
|
return createJarAndOutgoingConfiguration(name, sourceSets.named(name).get())
|
||||||
|
}
|
||||||
|
|
||||||
|
JarTaskSet createJarAndOutgoingConfiguration(String name, SourceSet... sourceSetSet) {
|
||||||
|
def config = configurations.register("common${name.capitalize()}") {
|
||||||
|
canBeConsumed = true
|
||||||
|
canBeResolved = false
|
||||||
|
}
|
||||||
|
def jarTask = tasks.register("${name}Jar", Jar) {
|
||||||
|
group = 'Build'
|
||||||
|
archiveClassifier.set(name)
|
||||||
|
destinationDirectory.set(project.layout.buildDirectory.dir('devlibs'))
|
||||||
|
for (SourceSet set in sourceSetSet) {
|
||||||
|
from set.output
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def remapJarTask = tasks.register("${name}RemapJar", RemapJarTask) {
|
||||||
|
group = 'Loom'
|
||||||
|
dependsOn(jarTask)
|
||||||
|
archiveClassifier.set(name)
|
||||||
|
inputFile.set(jarTask.flatMap { it.archiveFile })
|
||||||
|
}
|
||||||
|
def sourcesTask = tasks.register("${name}SourcesJar", Jar) {
|
||||||
|
group = 'Build'
|
||||||
|
archiveClassifier.set("${name}-sources")
|
||||||
|
destinationDirectory.set(project.layout.buildDirectory.dir('devlibs'))
|
||||||
|
for (SourceSet set in sourceSetSet) {
|
||||||
|
from set.allSource
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def remapSourcesTask = tasks.register("${name}RemapSourcesJar", RemapSourcesJarTask) {
|
||||||
|
group = 'Loom'
|
||||||
|
dependsOn(sourcesTask)
|
||||||
|
archiveClassifier.set("${name}-sources")
|
||||||
|
inputFile.set(sourcesTask.flatMap { it.archiveFile })
|
||||||
|
}
|
||||||
|
def javadocTask = tasks.register("${name}Javadoc", Javadoc) {
|
||||||
|
group = 'Build'
|
||||||
|
destinationDir = project.layout.buildDirectory.dir("docs/${name}-javadoc").get().asFile
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
for (SourceSet set in sourceSetSet) {
|
||||||
|
source set.allJava
|
||||||
|
classpath += set.compileClasspath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def javadocJarTask = tasks.register("${name}JavadocJar", Jar) {
|
||||||
|
group = 'Build'
|
||||||
|
dependsOn(javadocTask)
|
||||||
|
archiveClassifier.set("${name}-javadoc")
|
||||||
|
destinationDirectory.set(project.layout.buildDirectory.dir('libs'))
|
||||||
|
from(javadocTask.map { it.outputs })
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts.add(config.name, jarTask)
|
||||||
|
|
||||||
|
tasks.named('assemble').configure {
|
||||||
|
dependsOn(jarTask, remapJarTask, sourcesTask, remapSourcesTask, javadocTask, javadocJarTask)
|
||||||
|
}
|
||||||
|
|
||||||
|
return new JarTaskSet(jarTask, remapJarTask, sourcesTask, remapSourcesTask, javadocJarTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ plugins {
|
||||||
id 'flywheel.java'
|
id 'flywheel.java'
|
||||||
id 'flywheel.package-infos'
|
id 'flywheel.package-infos'
|
||||||
id 'flywheel.subproject'
|
id 'flywheel.subproject'
|
||||||
|
id 'flywheel.outgoing-configuration'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
@ -39,30 +40,31 @@ sourceSets {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name) {
|
jar {
|
||||||
return createJarAndOutgoingConfiguration(name, sourceSets.named(name).get())
|
from sourceSets.api.output
|
||||||
|
from sourceSets.lib.output
|
||||||
|
from sourceSets.backend.output
|
||||||
|
archiveClassifier.set('')
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name, SourceSet sourceSet) {
|
sourcesJar {
|
||||||
def config = configurations.register("common${name.capitalize()}") {
|
from sourceSets.api.allSource
|
||||||
canBeConsumed = true
|
from sourceSets.lib.allSource
|
||||||
canBeResolved = false
|
from sourceSets.backend.allSource
|
||||||
}
|
}
|
||||||
def jarTask = tasks.register("${name}Jar", Jar) {
|
|
||||||
archiveClassifier.set(name)
|
|
||||||
from sourceSet.output
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts.add(config.name, jarTask)
|
javadoc {
|
||||||
|
source sourceSets.api.allJava
|
||||||
return jarTask
|
source sourceSets.lib.allJava
|
||||||
|
source sourceSets.backend.allJava
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: repackage these for maven publication
|
// TODO: repackage these for maven publication
|
||||||
def apiJar = createJarAndOutgoingConfiguration("api")
|
outgoing.createJarAndOutgoingConfiguration("apiOnly", sourceSets.api)
|
||||||
def libJar = createJarAndOutgoingConfiguration("lib")
|
outgoing.createJarAndOutgoingConfiguration("lib")
|
||||||
def backendJar = createJarAndOutgoingConfiguration("backend")
|
def apiLibJar = outgoing.createJarAndOutgoingConfiguration("api", sourceSets.api, sourceSets.lib)
|
||||||
def implJar = createJarAndOutgoingConfiguration("impl", sourceSets.main)
|
def backendJar = outgoing.createJarAndOutgoingConfiguration("backend")
|
||||||
|
def implJar = outgoing.createJarAndOutgoingConfiguration("impl", sourceSets.main)
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||||
|
@ -78,11 +80,30 @@ publishing {
|
||||||
publications {
|
publications {
|
||||||
register('mavenIntermediary', MavenPublication) {
|
register('mavenIntermediary', MavenPublication) {
|
||||||
from(components['java'])
|
from(components['java'])
|
||||||
|
artifact apiLibJar.remapJar
|
||||||
|
artifact apiLibJar.remapSources
|
||||||
|
artifact apiLibJar.javadocJar
|
||||||
|
artifact backendJar.remapJar
|
||||||
|
artifact backendJar.remapSources
|
||||||
|
artifact backendJar.javadocJar
|
||||||
|
artifact implJar.remapJar
|
||||||
|
artifact implJar.remapSources
|
||||||
|
artifact implJar.javadocJar
|
||||||
artifactId = "flywheel-${project.name}-intermediary-${artifact_minecraft_version}"
|
artifactId = "flywheel-${project.name}-intermediary-${artifact_minecraft_version}"
|
||||||
}
|
}
|
||||||
register('mavenMojmap', MavenPublication) {
|
register('mavenMojmap', MavenPublication) {
|
||||||
artifact jar
|
artifact jar
|
||||||
artifact sourcesJar
|
artifact sourcesJar
|
||||||
|
artifact javadocJar
|
||||||
|
artifact apiLibJar.jar
|
||||||
|
artifact apiLibJar.sources
|
||||||
|
artifact apiLibJar.javadocJar
|
||||||
|
artifact backendJar.jar
|
||||||
|
artifact backendJar.sources
|
||||||
|
artifact backendJar.javadocJar
|
||||||
|
artifact implJar.jar
|
||||||
|
artifact implJar.sources
|
||||||
|
artifact implJar.javadocJar
|
||||||
artifactId = "flywheel-${project.name}-mojmap-${artifact_minecraft_version}"
|
artifactId = "flywheel-${project.name}-mojmap-${artifact_minecraft_version}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ dependencies {
|
||||||
modCompileOnly "maven.modrinth:sodium:${sodium_version}"
|
modCompileOnly "maven.modrinth:sodium:${sodium_version}"
|
||||||
modCompileOnly "maven.modrinth:iris:${iris_version}"
|
modCompileOnly "maven.modrinth:iris:${iris_version}"
|
||||||
|
|
||||||
forApi project(path: ':common', configuration: 'commonApi')
|
forApi project(path: ':common', configuration: 'commonApiOnly')
|
||||||
forLib project(path: ':common', configuration: 'commonLib')
|
forLib project(path: ':common', configuration: 'commonLib')
|
||||||
forBackend project(path: ':common', configuration: 'commonBackend')
|
forBackend project(path: ':common', configuration: 'commonBackend')
|
||||||
forImpl project(path: ':common', configuration: 'commonImpl')
|
forImpl project(path: ':common', configuration: 'commonImpl')
|
||||||
|
|
|
@ -53,7 +53,7 @@ dependencies {
|
||||||
modCompileOnly "maven.modrinth:embeddium:${embeddium_version}"
|
modCompileOnly "maven.modrinth:embeddium:${embeddium_version}"
|
||||||
modCompileOnly "maven.modrinth:oculus:${oculus_version}"
|
modCompileOnly "maven.modrinth:oculus:${oculus_version}"
|
||||||
|
|
||||||
forApi project(path: ':common', configuration: 'commonApi')
|
forApi project(path: ':common', configuration: 'commonApiOnly')
|
||||||
forLib project(path: ':common', configuration: 'commonLib')
|
forLib project(path: ':common', configuration: 'commonLib')
|
||||||
forBackend project(path: ':common', configuration: 'commonBackend')
|
forBackend project(path: ':common', configuration: 'commonBackend')
|
||||||
forImpl project(path: ':common', configuration: 'commonImpl')
|
forImpl project(path: ':common', configuration: 'commonImpl')
|
||||||
|
|
Loading…
Reference in a new issue