Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adventure: Complete the adventure #40

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ build/
libs/

*.log*

# Jetbrains IDE
.idea
13 changes: 5 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,23 @@ plugins {

configureArtifactory()

repositories {
jcenter()
}

release {
tagTemplate = "v\${version}"
buildTasks = listOf<String>()
}

val totalReport = tasks.register<JacocoReport>("jacocoTotalReport") {
subprojects.forEach { proj ->
for (proj in subprojects) {
proj.apply(plugin = "jacoco")
proj.plugins.withId("java") {
executionData(
fileTree(proj.buildDir.absolutePath).include("**/jacoco/*.exec")
)
sourceSets(proj.the<JavaPluginConvention>().sourceSets["main"])
reports {
xml.isEnabled = true
xml.destination = rootProject.buildDir.resolve("reports/jacoco/report.xml")
html.isEnabled = true
xml.required.set(true)
xml.outputLocation.set(rootProject.buildDir.resolve("reports/jacoco/report.xml"))
html.required.set(true)
}
dependsOn(proj.tasks.named("test"))
}
Expand Down
7 changes: 3 additions & 4 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ plugins {
}

repositories {
jcenter()
gradlePluginPortal()
maven {
name = "EngineHub Repository"
Expand All @@ -15,7 +14,7 @@ repositories {
dependencies {
implementation(gradleApi())
implementation(gradleKotlinDsl())
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.1.0-SNAPSHOT")
implementation("gradle.plugin.net.minecrell:licenser:0.4.1")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.13.0")
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.1.0")
implementation("gradle.plugin.org.cadixdev.gradle:licenser:0.6.1")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.29.0")
}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/Libs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ object Libs {
const val junitEngine = "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
const val junitVintageEngine = "org.junit.vintage:junit-vintage-engine:$junitVersion"
const val guava = "com.google.guava:guava"
private const val kyoriTextVersion = "3.0.4"
const val kyoriText = "net.kyori:text-api:$kyoriTextVersion"
const val kyoriTextPlain = "net.kyori:text-serializer-plain:$kyoriTextVersion"
private const val kyoriAdventureVersion = "4.14.0"
const val kyoriAdventure = "net.kyori:adventure-api:$kyoriAdventureVersion"
const val kyoriAdventureTextPlain = "net.kyori:adventure-text-serializer-plain:$kyoriAdventureVersion"
const val autoCommon = "com.google.auto:auto-common:0.11"
private const val autoValueVersion = "1.7.4"
const val autoValueAnnotations = "com.google.auto.value:auto-value-annotations:$autoValueVersion"
Expand All @@ -18,6 +18,6 @@ object Libs {
const val log4jApi = "org.apache.logging.log4j:log4j-api:$log4jVersion"
const val log4jCore = "org.apache.logging.log4j:log4j-core:$log4jVersion"
const val javaxAnnotations = "com.google.code.findbugs:jsr305:3.0.2"
const val compileTesting = "com.google.testing.compile:compile-testing:0.19"
const val compileTesting = "com.google.testing.compile:compile-testing:0.21.0"
const val mockito = "org.mockito:mockito-core:3.8.0"
}
23 changes: 13 additions & 10 deletions buildSrc/src/main/kotlin/common.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import net.minecrell.gradle.licenser.LicenseExtension
import org.gradle.api.JavaVersion
import org.cadixdev.gradle.licenser.LicenseExtension
import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.api.tasks.bundling.Jar
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.api.tasks.testing.Test
Expand All @@ -32,17 +29,17 @@ fun Project.applyCommonConfig(
) {
apply(plugin = "java-library")
apply(plugin = "java")
apply(plugin = "net.minecrell.licenser")
apply(plugin = "org.cadixdev.licenser")
apply(plugin = "maven-publish")
apply(plugin = "com.jfrog.artifactory")
apply(plugin = "jacoco")

project.group = group

configure<LicenseExtension> {
header = rootProject.file("HEADER.txt")
exclude("**/META-INF/**")
exclude("**/*.properties")
header(rootProject.file("HEADER.txt"))
include("**/*.java")
include("**/*.kt")
}

tasks.withType<Test>().configureEach {
Expand Down Expand Up @@ -73,8 +70,14 @@ fun Project.applyCommonConfig(
from(rootProject.file("common-test-resources"))
}

configure<JavaPluginExtension> {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}
plugins.withId("java") {
the<JavaPluginExtension>().toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks.withType<Javadoc>().configureEach {
(options as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet")
Expand Down
4 changes: 2 additions & 2 deletions core-ap/processor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import org.gradle.internal.jvm.Jvm
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.4.31"
kotlin("kapt") version "1.4.31"
kotlin("jvm") version "1.9.0"
kotlin("kapt") version "1.9.0"
}

applyCoreApConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import com.google.common.collect.ImmutableList;
import com.squareup.javapoet.CodeBlock;
import com.squareup.javapoet.TypeName;
import net.kyori.text.TextComponent;
import net.kyori.text.TranslatableComponent;
import net.kyori.adventure.text.Component;
import org.enginehub.piston.internal.RegistrationUtil;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -72,11 +71,11 @@ public static CodeBlock listForGen(Stream<CodeBlock> rawCode) {
}

public static CodeBlock textCompOf(String text) {
return CodeBlock.of("$T.of($S)", TextComponent.class, text);
return CodeBlock.of("$T.text($S)", Component.class, text);
}

public static CodeBlock transCompOf(String text) {
return CodeBlock.of("$T.of($S)", TranslatableComponent.class, text);
return CodeBlock.of("$T.translatable($S)", Component.class, text);
}

public static Collector<CodeBlock, ?, CodeBlock> joining(String delimiter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.enginehub.piston

import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.commands.RegressionCommands
import org.enginehub.piston.commands.RegressionCommandsRegistration
import org.enginehub.piston.converter.SimpleArgumentConverter
Expand All @@ -36,7 +36,6 @@ import org.junit.jupiter.api.assertThrows
import org.mockito.Mockito.mock
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import org.mockito.Mockito.verifyNoInteractions

@DisplayName("Regression tests")
class RegressionTest {
Expand Down Expand Up @@ -94,10 +93,10 @@ class RegressionTest {
action(it.valueOf(arg).asString())
1
}
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("Issue 9 #2"))
description(Component.text("Issue 9 #2"))
// Optional arg prior to sub-command
addPart(arg)
addPart(subs(sub))
Expand Down Expand Up @@ -137,11 +136,11 @@ class RegressionTest {
}
val sub = manager.newCommand("vert")
.action { SUB_ACTION }
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
action { ROOT_ACTION }
description(TextComponent.of("Issue 14"))
description(Component.text("Issue 14"))
addPart(subs(sub, required = false))
addPart(req)
addPart(optAfter)
Expand Down Expand Up @@ -171,10 +170,10 @@ class RegressionTest {
val sub = manager.newCommand("world")
.action { SUB_ACTION }
.aliases(setOf("there"))
.description(TextComponent.of("Sub-command"))
.description(Component.text("Sub-command"))
.build()
cmd.run {
description(TextComponent.of("hello"))
description(Component.text("hello"))
addPart(subs(sub, required = true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ package org.enginehub.piston

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableSet
import net.kyori.text.TextComponent
import net.kyori.text.TranslatableComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.gen.CommandRegistration
import org.enginehub.piston.part.ArgAcceptingCommandFlag
import org.enginehub.piston.part.CommandArgument
Expand Down Expand Up @@ -56,30 +55,30 @@ inline fun <reified CI> withMockedContainer(block: (CI) -> Unit) {

inline fun arg(name: String, desc: String, block: CommandArgument.Builder.() -> Unit = {}): CommandArgument =
CommandParts.arg(
TranslatableComponent.of(name),
TextComponent.of(desc)
Component.translatable(name),
Component.text(desc)
).also(block).build()

inline fun flag(name: Char, desc: String, block: NoArgCommandFlag.Builder.() -> Unit = {}): NoArgCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
).also(block).build()

inline fun argFlag(name: Char, desc: String, argName: String,
block: ArgAcceptingCommandFlag.Builder.() -> Unit = {}): ArgAcceptingCommandFlag =
CommandParts.flag(
name,
TextComponent.of(desc)
Component.text(desc)
)
.withRequiredArg()
.argNamed(argName)
.also(block).build()

fun subs(vararg subCommands: Command, required: Boolean = true): SubCommandPart =
SubCommandPart.builder(
TranslatableComponent.of("actions"),
TextComponent.of("Sub-actions")
Component.translatable("actions"),
Component.text("Sub-actions")
).run {
withCommands(ImmutableList.copyOf(subCommands))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

package org.enginehub.piston.suggestion

import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import org.enginehub.piston.Command
import org.enginehub.piston.CommandManager
import org.enginehub.piston.assertEqualUnordered
Expand Down Expand Up @@ -57,12 +58,12 @@ class ManagerSuggestionTest {
}

register("notpermitted") { cmd ->
cmd.description(TextComponent.of("Command with false condition"))
cmd.description(Component.text("Command with false condition"))
cmd.condition(Command.Condition.FALSE)
}

register("sub") { cmd ->
cmd.description(TextComponent.of("Sub-commands test command"))
cmd.description(Component.text("Sub-commands test command"))
cmd.addPart(subs(*allCommands.toList().toTypedArray()))
}
}
Expand Down Expand Up @@ -91,7 +92,7 @@ class ManagerSuggestionTest {
withSuggestionManager { manager ->
manager.registerManager(newManager().apply {
register("permitted") { cmd ->
cmd.description(TextComponent.of("Command with true condition"))
cmd.description(Component.text("Command with true condition"))
cmd.condition(Command.Condition.TRUE)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package org.enginehub.piston.suggestion

import net.kyori.text.Component
import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.TextComponent
import org.enginehub.piston.converter.ArgumentConverter
import org.enginehub.piston.converter.ConversionResult
import org.enginehub.piston.converter.FailedConversion
Expand All @@ -37,7 +37,7 @@ class SimpleSuggestingConverter(private val suggestions: List<String>) : Argumen
}

override fun describeAcceptableArguments(): Component {
return TextComponent.of("Any of $suggestions")
return Component.text("Any of $suggestions")
}

override fun getSuggestions(input: String, context: InjectedValueAccess): List<String> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.enginehub.piston.util

import com.google.common.collect.ImmutableList
import net.kyori.text.TextComponent
import net.kyori.adventure.text.Component
import org.enginehub.piston.TestCommandMetadata
import org.enginehub.piston.TestCommandParameters
import org.enginehub.piston.TestParseResult
Expand Down Expand Up @@ -98,7 +98,7 @@ class HelpGeneratorTest {
@Test
fun singleArgOptionalNotNoneHelp() {
val command = listOf(newManager().newCommand("single-arg-opt")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(
arg("piston.argument.first","First argument") {
defaultsTo(ImmutableList.of("a", "b"))
Expand All @@ -116,7 +116,7 @@ class HelpGeneratorTest {
@Test
fun flagsHelp() {
val command = listOf(newManager().newCommand("flags")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(
flag('f', "Flag"),
argFlag('q', "Quibble", "qux"),
Expand All @@ -138,12 +138,12 @@ class HelpGeneratorTest {
@Test
fun subCommandsHelp() {
val subCommand = newManager().newCommand("sub-command")
.description(TextComponent.of("sub-description"))
.description(Component.text("sub-description"))
.build()
val interArg = arg("intermediate", "inter-arg")
val subCommands = subs(subCommand)
val command = newManager().newCommand("main")
.description(TextComponent.of("description"))
.description(Component.text("description"))
.addParts(interArg, subCommands)
.build()
assertEquals("""
Expand Down Expand Up @@ -180,4 +180,4 @@ class HelpGeneratorTest {
).fullName))
}

}
}
Loading