Moved from Gradle to bld
This commit is contained in:
parent
7ef1c441e6
commit
d5e21dd3a1
194 changed files with 2185 additions and 1983 deletions
1
examples/.idea/.name
generated
1
examples/.idea/.name
generated
|
@ -1 +0,0 @@
|
|||
akismet-examples
|
55
examples/bld/.gitignore
vendored
Normal file
55
examples/bld/.gitignore
vendored
Normal 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
3
examples/bld/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
examples/bld/.idea/.name
generated
Normal file
1
examples/bld/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
|||
akismet-kotlin-examples-bld
|
30
examples/bld/.idea/app.iml
generated
Normal file
30
examples/bld/.idea/app.iml
generated
Normal 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
14
examples/bld/.idea/bld.iml
generated
Normal 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>
|
8
examples/bld/.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
8
examples/bld/.idea/inspectionProfiles/Project_Default.xml
generated
Normal 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
18
examples/bld/.idea/libraries/bld.xml
generated
Normal 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
13
examples/bld/.idea/libraries/compile.xml
generated
Normal 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
14
examples/bld/.idea/libraries/runtime.xml
generated
Normal 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
14
examples/bld/.idea/libraries/test.xml
generated
Normal 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
9
examples/bld/.idea/misc.xml
generated
Normal 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
9
examples/bld/.idea/modules.xml
generated
Normal 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>
|
9
examples/bld/.idea/runConfigurations/Run Tests.xml
generated
Normal file
9
examples/bld/.idea/runConfigurations/Run Tests.xml
generated
Normal 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
6
examples/bld/.idea/vcs.xml
generated
Normal 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
11
examples/bld/.vscode/launch.json
vendored
Normal 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
15
examples/bld/.vscode/settings.json
vendored
Normal 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
18
examples/bld/README.md
Normal 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
2
examples/bld/bld
Executable 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
4
examples/bld/bld.bat
Normal 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 %*
|
BIN
examples/bld/lib/bld/bld-wrapper.jar
Normal file
BIN
examples/bld/lib/bld/bld-wrapper.jar
Normal file
Binary file not shown.
7
examples/bld/lib/bld/bld-wrapper.properties
Normal file
7
examples/bld/lib/bld/bld-wrapper.properties
Normal 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
|
58
examples/bld/src/bld/java/com/example/ExampleBuild.java
Normal file
58
examples/bld/src/bld/java/com/example/ExampleBuild.java
Normal 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();
|
||||
}
|
||||
}
|
3
examples/gradle/.idea/.gitignore
generated
vendored
Normal file
3
examples/gradle/.idea/.gitignore
generated
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
1
examples/gradle/.idea/.name
generated
Normal file
1
examples/gradle/.idea/.name
generated
Normal file
|
@ -0,0 +1 @@
|
|||
akismet-examples-gradle
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel>
|
||||
<bytecodeTargetLevel target="11">
|
||||
<module name="akismet-sample.main" target="12" />
|
||||
<module name="akismet-sample.test" target="12" />
|
||||
</bytecodeTargetLevel>
|
17
examples/gradle/.idea/gradle.xml
generated
Normal file
17
examples/gradle/.idea/gradle.xml
generated
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
25
examples/gradle/.idea/jarRepositories.xml
generated
Normal file
25
examples/gradle/.idea/jarRepositories.xml
generated
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenLocal" />
|
||||
<option name="name" value="MavenLocal" />
|
||||
<option name="url" value="file:$MAVEN_REPOSITORY$/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
6
examples/gradle/.idea/kotlinc.xml
generated
Normal file
6
examples/gradle/.idea/kotlinc.xml
generated
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="version" value="1.9.20" />
|
||||
</component>
|
||||
</project>
|
|
@ -6,7 +6,10 @@
|
|||
<list size="0" />
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="12" project-jdk-type="JavaSDK" />
|
||||
<component name="PDMPlugin">
|
||||
<option name="skipTestSources" value="false" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="20" project-jdk-type="JavaSDK" />
|
||||
<component name="SuppressionsComponent">
|
||||
<option name="suppComments" value="[]" />
|
||||
</component>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
14
examples/gradle/README.md
Normal file
14
examples/gradle/README.md
Normal file
|
@ -0,0 +1,14 @@
|
|||
## Kotlin Example
|
||||
To compile & run the Kotlin example:
|
||||
|
||||
```text
|
||||
./gradlew run --args=API_KEY
|
||||
```
|
||||
|
||||
## Java Example
|
||||
|
||||
To compile & run the Java example:
|
||||
|
||||
```text
|
||||
./gradlew runJava --args=API_KEY
|
||||
```
|
|
@ -2,13 +2,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|||
|
||||
plugins {
|
||||
id("application")
|
||||
id("com.github.ben-manes.versions") version "0.48.0"
|
||||
kotlin("jvm") version "1.9.10"
|
||||
id("com.github.ben-manes.versions") version "0.49.0"
|
||||
kotlin("jvm") version "1.9.20"
|
||||
}
|
||||
|
||||
// ./gradlew run --args=API_KEY
|
||||
// ./gradlew runJava --args=API_KEY
|
||||
|
||||
defaultTasks(ApplicationPlugin.TASK_RUN_NAME)
|
||||
|
||||
repositories {
|
||||
|
@ -17,9 +14,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
// implementation("javax.servlet:javax.servlet-api:4.0.1")
|
||||
implementation("jakarta.servlet:jakarta.servlet-api:6.0.0")
|
||||
|
||||
implementation("net.thauvin.erik:akismet-kotlin:1.0.0")
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
14
examples/gradlew → examples/gradle/gradlew
vendored
14
examples/gradlew → examples/gradle/gradlew
vendored
|
@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
|
@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -202,11 +202,11 @@ fi
|
|||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
64
examples/gradle/src/main/java/com/example/AkismetSample.java
Normal file
64
examples/gradle/src/main/java/com/example/AkismetSample.java
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
}
|
||||
}
|
|
@ -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
|
||||
) {
|
||||
// ...
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue