Moved from Gradle to bld
This commit is contained in:
parent
594ca811e3
commit
3fa34848f5
111 changed files with 1008 additions and 1765 deletions
155
src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java
Normal file
155
src/bld/java/net/thauvin/erik/pinboard/PinboardPosterBuild.java
Normal file
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* PinboardPosterBuild.java
|
||||
*
|
||||
* Copyright 2021-2023 Erik C. Thauvin (erik@thauvin.net)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of this project nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.thauvin.erik.pinboard;
|
||||
|
||||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.extension.CompileKotlinOperation;
|
||||
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.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 PinboardPosterBuild extends Project {
|
||||
public PinboardPosterBuild() {
|
||||
pkg = "net.thauvin.erik.pinboard";
|
||||
name = "pinboard-poster";
|
||||
version = version(1, 1, 1, "SNAPSHOT");
|
||||
|
||||
mainClass = pkg + ".PinboardPoster";
|
||||
|
||||
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, 21)))
|
||||
.include(dependency("com.squareup.okhttp3", "okhttp", okHttp))
|
||||
.include(dependency("com.squareup.okhttp3", "logging-interceptor", okHttp));
|
||||
scope(test)
|
||||
.include(dependency("org.jetbrains.kotlin", "kotlin-test-junit5", version(1, 9, 21)))
|
||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 1)))
|
||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 1)));
|
||||
|
||||
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("net.thauvin.erik")
|
||||
.artifactId(name)
|
||||
.description("A small library for posting to Pinboard")
|
||||
.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 + ".git")
|
||||
.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(final String[] args) {
|
||||
new PinboardPosterBuild().start(args);
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Compiles the Kotlin project")
|
||||
@Override
|
||||
public void compile() throws IOException {
|
||||
new CompileKotlinOperation()
|
||||
.fromProject(this)
|
||||
.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("CryptoPrice")
|
||||
.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"));
|
||||
}
|
||||
}
|
|
@ -32,14 +32,16 @@
|
|||
|
||||
package net.thauvin.erik.pinboard
|
||||
|
||||
import org.testng.Assert.*
|
||||
import org.testng.annotations.Test
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
import java.time.ZonedDateTime
|
||||
import java.util.*
|
||||
import java.util.logging.Level
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class PinboardPosterTest {
|
||||
private val url = "http://www.example.com/?random=" + (1000..10000).random()
|
||||
|
@ -110,23 +112,24 @@ class PinboardPosterTest {
|
|||
}
|
||||
|
||||
var poster = PinboardPoster(props)
|
||||
poster.logger.level = Level.FINE
|
||||
if (!isCi) {
|
||||
poster.logger.level = Level.FINE
|
||||
}
|
||||
|
||||
poster.apiEndPoint = ""
|
||||
assertFalse(poster.deletePin(url), "apiEndPoint: <blank>")
|
||||
|
||||
poster = PinboardPoster(localProps, Constants.ENV_API_TOKEN)
|
||||
if (!isCi) {
|
||||
poster.logger.level = Level.FINE
|
||||
}
|
||||
|
||||
poster.apiEndPoint = Constants.API_ENDPOINT
|
||||
assertTrue(poster.addPin(url, desc), "addPin()")
|
||||
assertTrue(poster.deletePin(url), "apiEndPoint: ${Constants.API_ENDPOINT}")
|
||||
|
||||
expectThrows(IOException::class.java) {
|
||||
assertThrows<IOException> {
|
||||
poster.parseMethodResponse("post/delete", "<result code=\"item not found\"/>")
|
||||
}
|
||||
|
||||
expectThrows(IOException::class.java) {
|
||||
assertThrows<IOException> {
|
||||
poster.parseMethodResponse("post/delete", "")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue