mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-24 11:57: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 {
|
||||
plugins {
|
||||
simplePlugin {
|
||||
platformPlugin {
|
||||
id = 'flywheel.platform'
|
||||
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.package-infos'
|
||||
id 'flywheel.subproject'
|
||||
id 'flywheel.outgoing-configuration'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
@ -39,30 +40,31 @@ sourceSets {
|
|||
}
|
||||
}
|
||||
|
||||
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name) {
|
||||
return createJarAndOutgoingConfiguration(name, sourceSets.named(name).get())
|
||||
jar {
|
||||
from sourceSets.api.output
|
||||
from sourceSets.lib.output
|
||||
from sourceSets.backend.output
|
||||
archiveClassifier.set('')
|
||||
}
|
||||
|
||||
TaskProvider<Jar> createJarAndOutgoingConfiguration(String name, SourceSet sourceSet) {
|
||||
def config = configurations.register("common${name.capitalize()}") {
|
||||
canBeConsumed = true
|
||||
canBeResolved = false
|
||||
}
|
||||
def jarTask = tasks.register("${name}Jar", Jar) {
|
||||
archiveClassifier.set(name)
|
||||
from sourceSet.output
|
||||
}
|
||||
sourcesJar {
|
||||
from sourceSets.api.allSource
|
||||
from sourceSets.lib.allSource
|
||||
from sourceSets.backend.allSource
|
||||
}
|
||||
|
||||
artifacts.add(config.name, jarTask)
|
||||
|
||||
return jarTask
|
||||
javadoc {
|
||||
source sourceSets.api.allJava
|
||||
source sourceSets.lib.allJava
|
||||
source sourceSets.backend.allJava
|
||||
}
|
||||
|
||||
// TODO: repackage these for maven publication
|
||||
def apiJar = createJarAndOutgoingConfiguration("api")
|
||||
def libJar = createJarAndOutgoingConfiguration("lib")
|
||||
def backendJar = createJarAndOutgoingConfiguration("backend")
|
||||
def implJar = createJarAndOutgoingConfiguration("impl", sourceSets.main)
|
||||
outgoing.createJarAndOutgoingConfiguration("apiOnly", sourceSets.api)
|
||||
outgoing.createJarAndOutgoingConfiguration("lib")
|
||||
def apiLibJar = outgoing.createJarAndOutgoingConfiguration("api", sourceSets.api, sourceSets.lib)
|
||||
def backendJar = outgoing.createJarAndOutgoingConfiguration("backend")
|
||||
def implJar = outgoing.createJarAndOutgoingConfiguration("impl", sourceSets.main)
|
||||
|
||||
dependencies {
|
||||
modCompileOnly "net.fabricmc:fabric-loader:${fabric_loader_version}"
|
||||
|
@ -78,11 +80,30 @@ publishing {
|
|||
publications {
|
||||
register('mavenIntermediary', MavenPublication) {
|
||||
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}"
|
||||
}
|
||||
register('mavenMojmap', MavenPublication) {
|
||||
artifact jar
|
||||
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}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ dependencies {
|
|||
modCompileOnly "maven.modrinth:sodium:${sodium_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')
|
||||
forBackend project(path: ':common', configuration: 'commonBackend')
|
||||
forImpl project(path: ':common', configuration: 'commonImpl')
|
||||
|
|
|
@ -53,7 +53,7 @@ dependencies {
|
|||
modCompileOnly "maven.modrinth:embeddium:${embeddium_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')
|
||||
forBackend project(path: ':common', configuration: 'commonBackend')
|
||||
forImpl project(path: ':common', configuration: 'commonImpl')
|
||||
|
|
Loading…
Reference in a new issue