Skip to content

Commit

Permalink
Fix up some gradle config, use compat LM
Browse files Browse the repository at this point in the history
  • Loading branch information
octylFractal committed Mar 28, 2021
1 parent c19f63e commit a3e87f6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 22 deletions.
31 changes: 11 additions & 20 deletions buildSrc/src/main/kotlin/common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import org.jfrog.gradle.plugin.artifactory.dsl.PublisherConfig
import org.jfrog.gradle.plugin.artifactory.task.ArtifactoryTask

fun Project.applyCommonConfig(
group: String = rootProject.group.toString()
group: String = rootProject.group.toString()
) {
apply(plugin = "java-library")
apply(plugin = "java")
Expand All @@ -50,7 +50,7 @@ fun Project.applyCommonConfig(
}

repositories {
jcenter()
mavenCentral()
}

dependencies {
Expand Down Expand Up @@ -96,18 +96,9 @@ fun Project.applyCommonConfig(
}

private fun Project.addExtraArchiveArtifacts() {
val sourcesJar = tasks.register<Jar>("sourcesJar") {
dependsOn("classes")
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>().getByName("main").allSource)
}
val javadocJar = tasks.register<Jar>("javadocJar") {
dependsOn("javadoc")
archiveClassifier.set("javadoc")
from(tasks.getByName("javadoc"))
}
tasks.named("build") {
dependsOn(sourcesJar, javadocJar)
configure<JavaPluginExtension> {
withSourcesJar()
withJavadocJar()
}
}

Expand All @@ -119,8 +110,6 @@ private fun Project.configureMavenPublish() {
artifactId = project.name
version = project.version.toString()

artifact(tasks.getByName("sourcesJar"))
artifact(tasks.getByName("javadocJar"))
from(components["java"])
}
}
Expand All @@ -143,10 +132,12 @@ fun Project.configureArtifactory() {
setPublishIvy(false)
setPublishPom(true)
repository(delegateClosureOf<DoubleDelegateWrapper> {
invokeMethod("setRepoKey", when {
"SNAPSHOT" in project.version.toString() -> "libs-snapshot-local"
else -> "libs-release-local"
})
invokeMethod(
"setRepoKey", when {
"SNAPSHOT" in project.version.toString() -> "libs-snapshot-local"
else -> "libs-release-local"
}
)
invokeMethod("setUsername", project.property("artifactory_user"))
invokeMethod("setPassword", project.property("artifactory_password"))
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.google.common.collect.Iterators;
import net.kyori.text.Component;
import net.kyori.text.TextComponent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandMetadata;
Expand Down Expand Up @@ -70,7 +69,7 @@

class CommandParser {

private static final Logger LOGGER = LogManager.getLogger();
private static final Logger LOGGER = LogManagerCompat.getLogger();

private static final ThreadLocal<String> PARSE_ID = new ThreadLocal<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Piston, a flexible command management system.
* Copyright (C) EngineHub <https://www.enginehub.org>
* Copyright (C) Piston contributors
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package org.enginehub.piston.impl;

import com.google.common.base.Throwables;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.List;

/**
* Internal use only.
*/
public class LogManagerCompat {

public static Logger getLogger() {
return LogManager.getLogger(getCallerCallerClassName());
}

private static String getCallerCallerClassName() {
List<StackTraceElement> lazyStack = Throwables.lazyStackTrace(new Throwable());
// 0 - this method
// 1 - caller
// 2 - caller caller
return lazyStack.get(2).getClassName();
}

private LogManagerCompat() {
}
}

0 comments on commit a3e87f6

Please sign in to comment.