Moved from Gradle to bld

This commit is contained in:
Erik C. Thauvin 2023-11-12 15:12:11 -08:00
parent 7ef1c441e6
commit d5e21dd3a1
194 changed files with 2185 additions and 1983 deletions

55
examples/bld/.gitignore vendored Normal file
View file

@ -0,0 +1,55 @@
.gradle
.DS_Store
build
lib/bld/**
!lib/bld/bld-wrapper.jar
!lib/bld/bld-wrapper.properties
lib/compile/
lib/runtime/
lib/standalone/
lib/test/
# IDEA ignores
# User-specific
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Editor-based Rest Client
.idea/httpRequests

3
examples/bld/.idea/.gitignore generated vendored Normal file
View file

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

1
examples/bld/.idea/.name generated Normal file
View file

@ -0,0 +1 @@
akismet-kotlin-examples-bld

30
examples/bld/.idea/app.iml generated Normal file
View file

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/main" />
<output-test url="file://$MODULE_DIR$/build/test" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" relativeOutputPath="resources" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library" scope="RUNTIME">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/src/main/resources/templates" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="compile" level="project" />
<orderEntry type="library" scope="RUNTIME" name="runtime" level="project" />
<orderEntry type="library" scope="TEST" name="test" level="project" />
</component>
</module>

14
examples/bld/.idea/bld.iml generated Normal file
View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/bld" />
<output-test url="file://$MODULE_DIR$/build/bld" />
<exclude-output />
<content url="file://$MODULE_DIR$/src/bld">
<sourceFolder url="file://$MODULE_DIR$/src/bld/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="bld" level="project" />
</component>
</module>

View file

@ -0,0 +1,8 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ADDITIONAL_TAGS" value="created" />
</inspection_tool>
</profile>
</component>

18
examples/bld/.idea/libraries/bld.xml generated Normal file
View file

@ -0,0 +1,18 @@
<component name="libraryTable">
<library name="bld">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/bld" />
<root url="jar://$USER_HOME$/.bld/dist/bld-1.7.5-sources.jar!/" />
</SOURCES>
<excluded>
<root url="jar://$PROJECT_DIR$/lib/bld/bld-wrapper.jar!/" />
</excluded>
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/bld" recursive="false" type="SOURCES" />
</library>
</component>

13
examples/bld/.idea/libraries/compile.xml generated Normal file
View file

@ -0,0 +1,13 @@
<component name="libraryTable">
<library name="compile">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/compile" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/compile" recursive="false" type="SOURCES" />
</library>
</component>

14
examples/bld/.idea/libraries/runtime.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="runtime">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
<root url="file://$PROJECT_DIR$/src/main/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/runtime" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/runtime" recursive="false" type="SOURCES" />
</library>
</component>

14
examples/bld/.idea/libraries/test.xml generated Normal file
View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="test">
<CLASSES>
<root url="file://$PROJECT_DIR$/lib/test" />
<root url="file://$PROJECT_DIR$/src/test/resources" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/test" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/test" recursive="false" type="SOURCES" />
</library>
</component>

9
examples/bld/.idea/misc.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PDMPlugin">
<option name="skipTestSources" value="false" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build" />
</component>
</project>

9
examples/bld/.idea/modules.xml generated Normal file
View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,9 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Tests" type="Application" factoryName="Application" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="com.example.ExampleTest" />
<module name="app" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>

6
examples/bld/.idea/vcs.xml generated Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>

11
examples/bld/.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "Run Tests",
"request": "launch",
"mainClass": "com.example.ExampleTest"
}
]
}

15
examples/bld/.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
"java.project.sourcePaths": [
"src/main/java",
"src/main/resources",
"src/test/java",
"src/bld/java"
],
"java.configuration.updateBuildConfiguration": "automatic",
"java.project.referencedLibraries": [
"${HOME}/.bld/dist/bld-1.7.5.jar",
"lib/compile/*.jar",
"lib/runtime/*.jar",
"lib/test/*.jar"
]
}

18
examples/bld/README.md Normal file
View file

@ -0,0 +1,18 @@
## Kotlin Example
To compile & run the Kotlin example:
```text
./bld compile
./bld run --args=API_KEY
```
## Java Example
cd
To compile & run the Java example:
```text
./bld compile
./bld run-java --args=API_KEY
```

2
examples/bld/bld Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env sh
java -jar "$(dirname "$0")/lib/bld/bld-wrapper.jar" "$0" --build com.example.ExampleBuild "$@"

4
examples/bld/bld.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
java -jar "%DIRNAME%/lib/bld/bld-wrapper.jar" "%0" --build com.example.ExampleBuild %*

Binary file not shown.

View file

@ -0,0 +1,7 @@
bld.downloadExtensionJavadoc=false
bld.downloadExtensionSources=true
bld.extensions=com.uwyn.rife2:bld-kotlin:0.9.0-SNAPSHOT
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
bld.downloadLocation=
bld.sourceDirectories=
bld.version=1.7.5

View file

@ -0,0 +1,58 @@
package com.example;
import rife.bld.BaseProject;
import rife.bld.BuildCommand;
import rife.bld.extension.CompileKotlinOperation;
import rife.bld.extension.CompileKotlinOptions;
import rife.bld.operations.RunOperation;
import java.util.List;
import static rife.bld.dependencies.Repository.*;
import static rife.bld.dependencies.Scope.compile;
public class ExampleBuild extends BaseProject {
public ExampleBuild() {
pkg = "com.example";
name = "Example";
version = version(0, 1, 0);
mainClass = "com.example.AkismetExampleKt";
javaRelease = 11;
downloadSources = true;
autoDownloadPurge = true;
repositories = List.of(MAVEN_LOCAL, MAVEN_CENTRAL, SONATYPE_SNAPSHOTS_LEGACY);
scope(compile)
.include(dependency("net.thauvin.erik:akismet-kotlin:1.0.0"))
.include(dependency("jakarta.servlet:jakarta.servlet-api:6.0.0"));
}
public static void main(String[] args) {
new ExampleBuild().start(args);
}
@Override
public void compile() throws Exception {
new CompileKotlinOperation()
.fromProject(this)
.compileOptions(
new CompileKotlinOptions()
.jdkRelease(javaRelease)
.verbose(true)
)
.execute();
// Also compile the Java source code
super.compile();
}
@BuildCommand(value = "run-java", summary = "Runs the Java example")
public void runJava() throws Exception {
new RunOperation()
.fromProject(this)
.mainClass("com.example.AkismetSample")
.execute();
}
}

View file

@ -0,0 +1,64 @@
package com.example;
import net.thauvin.erik.akismet.Akismet;
import net.thauvin.erik.akismet.AkismetComment;
import java.util.Date;
public class AkismetSample {
public static void main(String... args) {
if (args.length == 1 && !args[0].isBlank()) {
final Akismet akismet = new Akismet(args[0], "https://yourblogdomainname.com/blog/");
final AkismetComment comment = new AkismetComment("127.0.0.1", "curl/7.29.0");
comment.setTest(true);
comment.setReferrer("https://www.google.com");
comment.setPermalink(akismet.getBlog() + "post=1");
comment.setType(AkismetComment.TYPE_COMMENT);
comment.setAuthor("admin");
comment.setAuthorEmail("test@test.com");
comment.setAuthorUrl("http://www.CheckOutMyCoolSite.com");
comment.setDateGmt(Akismet.dateToGmt(new Date()));
// comment.setUserRole(AkismetComment.ADMIN_ROLE);
comment.setContent("It means a lot that you would take the time to review our software. Thanks again.");
// final ConsoleHandler consoleHandler = new ConsoleHandler();
// consoleHandler.setLevel(Level.FINE);
// final Logger logger = akismet.getLogger();
// logger.addHandler(consoleHandler);
// logger.setLevel(Level.FINE);
if (akismet.verifyKey()) {
final boolean isSpam = akismet.checkComment(comment);
if (isSpam) {
System.out.println("The comment is SPAM according to Akismet.");
final boolean hasBeenSubmitted = akismet.submitSpam(comment);
if (hasBeenSubmitted) {
System.out.println("The comment has been submitted as SPAM to Akismet");
} else {
System.err.println(akismet.getErrorMessage());
}
} else {
System.out.println("The comment is not SPAM according to Akismet.");
final boolean hasBeenSubmitted = akismet.submitHam(comment);
if (hasBeenSubmitted) {
System.out.println("The comment has been submitted as HAM to Akismet");
} else {
System.err.println(akismet.getErrorMessage());
}
}
} else {
System.err.println("Invalid API Key.");
System.exit(1);
}
System.exit(0);
} else {
System.err.println("Please specify an API key.");
System.exit(1);
}
}
}

View file

@ -0,0 +1,66 @@
package com.example
import net.thauvin.erik.akismet.Akismet
import net.thauvin.erik.akismet.AkismetComment
import java.util.Date
import kotlin.system.exitProcess
fun main(args: Array<String>) {
if (args.size == 1 && args[0].isNotEmpty()) {
val akismet = Akismet(apiKey = args[0], blog = "https://yourblogdomainname.com/blog/")
val comment = AkismetComment(userIp = "127.0.0.1", userAgent = "curl/7.29.0")
with(comment) {
isTest = true
referrer = "https://www.google.com"
permalink = "${akismet.blog}post=1"
type = AkismetComment.TYPE_COMMENT
author = "admin"
authorEmail = "test@test.com"
authorUrl = "https://www.CheckOutMyCoolSite.com"
dateGmt = Akismet.dateToGmt(Date())
// userRole = AkismetComment.ADMIN_ROLE
content = "It means a lot that you would take the time to review our software. Thanks again."
}
// with(akismet.logger) {
// addHandler(ConsoleHandler().apply { level = Level.FINE })
// level = Level.FINE
// }
if (akismet.verifyKey()) {
val isSpam = akismet.checkComment(comment)
if (isSpam) {
println("The comment is SPAM according to Akismet.")
val hasBeenSubmitted = akismet.submitSpam(comment)
if (hasBeenSubmitted) {
println("The comment was successfully submitted as SPAM to Akismet.")
} else {
System.err.println(akismet.errorMessage)
}
} else {
println("The comment is not SPAM according to Akismet.")
val hasBeenSubmitted = akismet.submitHam(comment)
if (hasBeenSubmitted) {
println("The comment was successfully submitted as HAM to Akismet.")
} else {
System.err.println(akismet.errorMessage)
}
}
} else {
System.err.println("Invalid API Key.")
exitProcess(1)
}
exitProcess(0)
} else {
System.err.println("Please specify an API key.")
exitProcess(1)
}
}

View file

@ -0,0 +1,60 @@
package com.example
import jakarta.servlet.ServletException
import jakarta.servlet.annotation.WebServlet
import jakarta.servlet.http.HttpServlet
import jakarta.servlet.http.HttpServletRequest
import jakarta.servlet.http.HttpServletResponse
import net.thauvin.erik.akismet.Akismet
import net.thauvin.erik.akismet.AkismetComment
import java.io.IOException
import java.util.Date
@WebServlet(description = "Akismet Servlet", displayName = "Akismet", urlPatterns = ["/comment/*"])
class AkismetServlet : HttpServlet() {
private val akismet = Akismet("YOUR_API_KEY", "http://yourblogdomainname.com/blog/")
@Throws(ServletException::class, IOException::class)
public override fun service(request: HttpServletRequest, response: HttpServletResponse) {
val id = request.getParameter("id")
akismet.appUserAgent = request.servletContext.serverInfo
val comment = AkismetComment(request)
with(comment) {
permalink = "${akismet.blog}/comment/$id"
type = AkismetComment.TYPE_COMMENT
author = request.getParameter("name")
authorEmail = request.getParameter("email")
dateGmt = Akismet.dateToGmt(Date())
content = request.getParameter("comment")
}
val isSpam = akismet.checkComment(comment)
saveComment(
id = id,
name = comment.author,
email = comment.authorEmail,
date = comment.dateGmt,
comment = comment.content,
json = comment.toJson(),
isSpam = isSpam
)
// ...
}
@Suppress("UNUSED_PARAMETER")
private fun saveComment(
id: String,
name: String?,
email: String?,
date: String?,
comment: String?,
json: String,
isSpam: Boolean
) {
// ...
}
}