Moved from Gradle to bld

This commit is contained in:
Erik C. Thauvin 2023-11-11 21:26:13 -08:00
parent 886ed86479
commit f8cf0fd338
321 changed files with 12452 additions and 1492 deletions

View file

@ -0,0 +1,146 @@
package net.thauvin.erik.bitly;
import rife.bld.BuildCommand;
import rife.bld.Project;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.CompileKotlinOptions;
import rife.bld.extension.JacocoReportOperation;
import rife.bld.extension.dokka.DokkaOperation;
import rife.bld.extension.dokka.LoggingLevel;
import rife.bld.extension.dokka.OutputFormat;
import rife.bld.extension.dokka.SourceSet;
import rife.bld.operations.exceptions.ExitStatusException;
import rife.bld.publish.PomBuilder;
import rife.bld.publish.PublishDeveloper;
import rife.bld.publish.PublishLicense;
import rife.bld.publish.PublishScm;
import rife.tools.exceptions.FileUtilsErrorException;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
import static rife.bld.dependencies.Scope.test;
public class BitlyShortenBuild extends Project {
public BitlyShortenBuild() {
pkg = "net.thauvin.erik";
name = "bitly-shorten";
version = version(1, 0, 2, "SNAPSHOT");
javaRelease = 11;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL);
var okHttp = version(4, 12, 0);
scope(compile)
.include(dependency("org.jetbrains.kotlin", "kotlin-stdlib", version(1, 9, 20)))
.include(dependency("com.squareup.okhttp3", "okhttp", okHttp))
.include(dependency("com.squareup.okhttp3", "logging-interceptor", okHttp))
.include(dependency("org.json", "json", "20231013"));
scope(test)
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", version(1, 9, 20)))
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)))
.include(dependency("com.willowtreeapps.assertk", "assertk-jvm", version(0, 27, 0)));
publishOperation()
.repository(version.isSnapshot() ? repository(SONATYPE_SNAPSHOTS_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password"))
: repository(SONATYPE_RELEASES_LEGACY.location())
.withCredentials(property("sonatype.user"), property("sonatype.password")))
.info()
.groupId(pkg)
.artifactId(name)
.description("A simple implementation of the Bitly link shortening API v4")
.url("https://github.com/ethauvin/" + name)
.developer(new PublishDeveloper()
.id("ethauvin")
.name("Erik C. Thauvin")
.email("erik@thauvin.net")
.url("https://erik.thauvin.net/"))
.license(new PublishLicense()
.name("BSD 3-Clause")
.url("https://opensource.org/licenses/BSD-3-Clause"))
.scm(new PublishScm()
.connection("scm:git:https://github.com/ethauvin/" + name)
.developerConnection("scm:git:git@github.com:ethauvin/" + name + ".git")
.url("https://github.com/ethauvin/" + name))
.signKey(property("sign.key"))
.signPassphrase(property("sign.passphrase"));
jarSourcesOperation().sourceDirectories(new File(srcMainDirectory(), "kotlin"));
}
public static void main(String[] args) {
new BitlyShortenBuild().start(args);
}
@BuildCommand(summary = "Compiles the Kotlin project")
@Override
public void compile() throws IOException {
new CompileKotlinOperation()
.fromProject(this)
.compileOptions(
new CompileKotlinOptions()
.jdkRelease(javaRelease)
.verbose(true)
)
.execute();
}
@BuildCommand(value = "dokka-html", summary = "Generates documentation in HTML format")
public void dokkaHtml() throws ExitStatusException, IOException, InterruptedException {
var kotlin = new File(srcMainDirectory(), "kotlin").getAbsolutePath();
new DokkaOperation()
.fromProject(this)
.loggingLevel(LoggingLevel.INFO)
.moduleName("Bitly-Shorten")
.moduleVersion(version.toString())
.outputDir("docs")
.outputFormat(OutputFormat.HTML)
.includes("config/dokka/packages.md")
.sourceSet(
new SourceSet()
.src(kotlin)
.srcLink(kotlin, "https://github.com/ethauvin/" + name +
"/tree/master/src/main/kotlin/", "#L")
.includes("config/dokka/packages.md")
)
.execute();
}
@BuildCommand(summary = "Generates JaCoCo Reports")
public void jacoco() throws IOException {
new JacocoReportOperation()
.fromProject(this)
.execute();
}
@Override
public void javadoc() throws ExitStatusException, IOException, InterruptedException {
new DokkaOperation()
.fromProject(this)
.loggingLevel(LoggingLevel.INFO)
.moduleName("Bitly-Shorten")
.moduleVersion(version.toString())
.outputDir(new File(buildDirectory(), "javadoc"))
.outputFormat(OutputFormat.JAVADOC)
.execute();
}
@Override
public void publish() throws Exception {
super.publish();
pomRoot();
}
@BuildCommand(value = "pom-root", summary = "Generates the POM file in the root directory")
public void pomRoot() throws FileUtilsErrorException {
PomBuilder.generateInto(publishOperation().fromProject(this).info(), dependencies(),
new File(workDirectory, "pom.xml"));
}
}

View file

@ -40,7 +40,6 @@ import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONException
import org.json.JSONObject
import java.net.MalformedURLException
import java.net.URI
import java.net.URISyntaxException
import java.util.logging.Level

View file

@ -41,6 +41,7 @@ import net.thauvin.erik.bitly.config.CreateConfig
import net.thauvin.erik.bitly.config.UpdateConfig
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeAll
import java.io.File
import java.util.logging.Level
import kotlin.test.*
@ -56,13 +57,6 @@ class BitlyTest {
private val longUrl = "https://erik.thauvin.net/blog"
private val shortUrl = "https://bit.ly/380ojFd"
@Before
fun before() {
with(Utils.logger) {
level = Level.FINE
}
}
@Test
fun `token should be specified`() {
val test = Bitly()
@ -283,4 +277,14 @@ class BitlyTest {
assertTrue("https://www.example.com".isValidUrl(), "valid url")
assertFalse("this is a test".isValidUrl(), "invalid url")
}
companion object {
@JvmStatic
@BeforeAll
fun before() {
with(Utils.logger) {
level = Level.FINE
}
}
}
}