Skip to content

Commit 60e7fdf

Browse files
feat: unify Java SDK 4.6.6 with HTTPS API, LTS CI, tests and docs
1 parent d3a3343 commit 60e7fdf

96 files changed

Lines changed: 9510 additions & 2667 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# DeathByCaptcha API Credentials Configuration Example
2+
# Copy this file to 'credentials.properties' and fill in your actual credentials
3+
# NEVER commit credentials.properties to version control
4+
5+
# Authentication Method 1: Username + Password
6+
DBC_USERNAME=your_username_here
7+
DBC_PASSWORD=your_password_here
8+
9+
# Authentication Method 2: Auth Token (alternative to username/password)
10+
# Uncomment and use this if you prefer token authentication
11+
# DBC_AUTHTOKEN=your_authtoken_here
12+
13+
# API Configuration
14+
# Use HTTPS endpoint (recommended for security)
15+
DBC_API_URL=https://api.dbcapi.me/api
16+
17+
# Socket API Configuration (optional, for SocketClient)
18+
DBC_SOCKET_HOST=api.dbcapi.me
19+
DBC_SOCKET_PORT=8123
20+
21+
# Proxy Configuration (optional)
22+
# Uncomment and configure if you need to use a proxy
23+
# PROXY_URL=http://127.0.0.1:3128
24+
# PROXY_USERNAME=
25+
# PROXY_PASSWORD=
26+
# PROXY_TYPE=HTTP
27+
28+
# Client Configuration
29+
CLIENT_VERBOSE=true
30+
CLIENT_TIMEOUT=60
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Java LTS Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
9+
jobs:
10+
java_lts_tests:
11+
name: Java ${{ matrix.java }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
java: [17, 21, 25]
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Java ${{ matrix.java }}
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: temurin
27+
java-version: ${{ matrix.java }}
28+
cache: maven
29+
30+
- name: Show tool versions
31+
run: |
32+
java -version
33+
mvn -version
34+
35+
- name: Run tests
36+
run: mvn --batch-mode --errors --fail-at-end --show-version -Djava.release=${{ matrix.java }} clean test
37+
38+
- name: Print core coverage
39+
if: always()
40+
run: |
41+
if [ -f target/site/jacoco/jacoco.csv ]; then
42+
awk -F',' 'NR>1 && $2 == "com.DeathByCaptcha" { missed += $4; covered += $5 } END { total = missed + covered; pct = (total > 0 ? (covered * 100.0 / total) : 0); printf "Coverage (core): %.2f%%\n", pct }' target/site/jacoco/jacoco.csv
43+
else
44+
echo "Coverage (core): N/A (jacoco.csv not found)"
45+
fi
46+
47+
- name: Write coverage summary
48+
if: always()
49+
run: |
50+
if [ -f target/site/jacoco/jacoco.csv ]; then
51+
CORE_COVERAGE=$(awk -F',' 'NR>1 && $2 == "com.DeathByCaptcha" { missed += $4; covered += $5 } END { total = missed + covered; pct = (total > 0 ? (covered * 100.0 / total) : 0); printf "%.2f", pct }' target/site/jacoco/jacoco.csv)
52+
{
53+
echo "### Java ${{ matrix.java }}"
54+
echo "- Coverage (core): ${CORE_COVERAGE}%"
55+
} >> "$GITHUB_STEP_SUMMARY"
56+
else
57+
{
58+
echo "### Java ${{ matrix.java }}"
59+
echo "- Coverage (core): N/A"
60+
} >> "$GITHUB_STEP_SUMMARY"
61+
fi
62+
63+
- name: Upload test and coverage artifacts
64+
if: always()
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: test-results-java-${{ matrix.java }}
68+
path: |
69+
target/surefire-reports/
70+
target/site/jacoco/

.gitignore

Lines changed: 92 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Compiled class file
1+
# Compiled class files
22
*.class
33

4-
# Log file
4+
# Log files
55
*.log
66

77
# BlueJ files
@@ -10,7 +10,7 @@
1010
# Mobile Tools for Java (J2ME)
1111
.mtj.tmp/
1212

13-
# Package Files #
13+
# Package Files
1414
*.jar
1515
*.war
1616
*.nar
@@ -19,5 +19,93 @@
1919
*.tar.gz
2020
*.rar
2121

22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
22+
# Virtual machine crash logs
2323
hs_err_pid*
24+
25+
# Maven
26+
target/
27+
pom.xml.tag
28+
pom.xml.releaseBackup
29+
pom.xml.versionsBackup
30+
pom.xml.next
31+
release.properties
32+
dependency-reduced-pom.xml
33+
buildNumber.properties
34+
.mvn/timing.properties
35+
.mvn/wrapper/maven-wrapper.jar
36+
37+
# Eclipse
38+
.classpath
39+
.project
40+
.settings/
41+
bin/
42+
43+
# IntelliJ IDEA
44+
.idea/
45+
*.iml
46+
*.iws
47+
*.ipr
48+
out/
49+
50+
# NetBeans
51+
nbproject/private/
52+
build/
53+
nbbuild/
54+
dist/
55+
nbdist/
56+
.nb-gradle/
57+
58+
# VS Code
59+
.vscode/
60+
61+
# macOS
62+
.DS_Store
63+
64+
# Windows
65+
Thumbs.db
66+
Desktop.ini
67+
68+
# Backup files
69+
*~
70+
*.bak
71+
*.swp
72+
*.swo
73+
74+
# Documentation
75+
docs/generated/
76+
77+
# Credentials (never commit)
78+
.env
79+
.env.*
80+
!.env.example
81+
credentials.txt
82+
config.properties
83+
*.key
84+
*.pem
85+
*.p12
86+
*.jks
87+
id_rsa
88+
id_rsa.pub
89+
secrets.*
90+
91+
# Test output
92+
test-output/
93+
*.log
94+
95+
# Selenium
96+
chromedriver
97+
geckodriver
98+
*.exe
99+
100+
# Local CI/dev artifacts
101+
.gitlab-ci-local/
102+
.m2/
103+
.tmp/
104+
tmp/
105+
106+
# Coverage and reports
107+
coverage/
108+
jacoco.exec
109+
110+
# OS/editor noise
111+
*.orig

.gitlab-ci.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
stages:
2+
- test
3+
4+
variables:
5+
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
6+
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
7+
8+
cache:
9+
key: "${CI_COMMIT_REF_SLUG}"
10+
paths:
11+
- .m2/repository
12+
13+
java_lts_tests:
14+
stage: test
15+
image: ${CI_JOB_IMAGE}
16+
coverage: '/Coverage \(core\):\s+([0-9]+(?:\.[0-9]+)?)%/'
17+
parallel:
18+
matrix:
19+
- JDK_VERSION: "17"
20+
CI_JOB_IMAGE: "maven:3.9.9-eclipse-temurin-17"
21+
- JDK_VERSION: "21"
22+
CI_JOB_IMAGE: "maven:3.9.9-eclipse-temurin-21"
23+
- JDK_VERSION: "25"
24+
CI_JOB_IMAGE: "maven:3-eclipse-temurin-25"
25+
26+
before_script:
27+
- java -version
28+
- |
29+
if ! command -v mvn >/dev/null 2>&1; then
30+
MAVEN_VERSION="3.9.9"
31+
MAVEN_DIR="$CI_PROJECT_DIR/.maven"
32+
MAVEN_TGZ="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
33+
MAVEN_URL="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_TGZ}"
34+
35+
mkdir -p "$MAVEN_DIR"
36+
if command -v curl >/dev/null 2>&1; then
37+
curl -fsSL "$MAVEN_URL" -o "$MAVEN_DIR/$MAVEN_TGZ"
38+
elif command -v wget >/dev/null 2>&1; then
39+
wget -qO "$MAVEN_DIR/$MAVEN_TGZ" "$MAVEN_URL"
40+
else
41+
echo "Neither curl nor wget is available to download Maven" >&2
42+
exit 1
43+
fi
44+
45+
tar -xzf "$MAVEN_DIR/$MAVEN_TGZ" -C "$MAVEN_DIR"
46+
export PATH="$MAVEN_DIR/apache-maven-${MAVEN_VERSION}/bin:$PATH"
47+
fi
48+
- mvn -version
49+
50+
script:
51+
- mvn ${MAVEN_CLI_OPTS} -Djava.release=${JDK_VERSION} clean test
52+
- |
53+
if [ -f target/site/jacoco/jacoco.csv ]; then
54+
awk -F',' 'NR>1 && $2 == "com.DeathByCaptcha" { missed += $4; covered += $5 } END { total = missed + covered; pct = (total > 0 ? (covered * 100.0 / total) : 0); printf "Coverage (core): %.2f%%\n", pct }' target/site/jacoco/jacoco.csv
55+
fi
56+
57+
artifacts:
58+
when: always
59+
expire_in: 1 week
60+
paths:
61+
- target/surefire-reports/
62+
- target/site/jacoco/
63+
reports:
64+
junit:
65+
- target/surefire-reports/*.xml
66+
67+
rules:
68+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
69+
- if: $CI_COMMIT_BRANCH

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "api-metadata"]
2+
path = api-metadata
3+
url = git@github.com:deathbycaptcha/deathbycaptcha-agent-api-metadata.git

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 DeathByCaptcha
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# DeathByCaptcha Unified Java SDK Makefile
2+
# This Makefile provides an alternative to Maven for building the project
3+
# For Maven users: use 'mvn clean install' instead
4+
5+
JAVAC = javac
6+
JAR = jar
7+
JAVADOC = javadoc
8+
9+
NAME = DeathByCaptcha
10+
SRC_DIR = src/main/java
11+
BUILD_DIR = target/classes
12+
JAR_DIR = target
13+
DOC_DIR = target/docs
14+
15+
OPT_SRC = $(SRC_DIR)/org/*/*.java
16+
LIB_SRC = $(SRC_DIR)/com/$(NAME)/*.java
17+
EXAMPLES_SRC = $(SRC_DIR)/examples/Example*.java
18+
19+
all: clean lib jar doc examples
20+
21+
clean:
22+
find $(SRC_DIR) -type f -name \*.class -delete 2>/dev/null || true
23+
rm -rf $(BUILD_DIR) $(JAR_DIR) $(DOC_DIR)
24+
mkdir -p $(BUILD_DIR) $(JAR_DIR) $(DOC_DIR)
25+
26+
.PHONY: lib
27+
lib: clean
28+
$(JAVAC) -d $(BUILD_DIR) $(OPT_SRC) $(LIB_SRC)
29+
30+
.PHONY: jar
31+
jar: lib
32+
mkdir -p $(JAR_DIR)
33+
$(JAR) cf $(JAR_DIR)/org.base64.jar -C $(BUILD_DIR) org/base64
34+
$(JAR) cf $(JAR_DIR)/org.json.jar -C $(BUILD_DIR) org/json
35+
$(JAR) cf $(JAR_DIR)/com.DeathByCaptcha.jar -C $(BUILD_DIR) com/DeathByCaptcha
36+
37+
.PHONY: doc
38+
doc:
39+
$(JAVADOC) -public -d $(DOC_DIR) $(LIB_SRC)
40+
41+
.PHONY: examples
42+
examples: lib
43+
$(JAVAC) -cp $(BUILD_DIR) -d $(BUILD_DIR) $(EXAMPLES_SRC)
44+
45+
.PHONY: package
46+
package: all
47+
zip -9rX deathbycaptcha-java-sdk.zip src/ pom.xml Makefile README.md LICENSE .gitignore -x \*/.git/\* \*/target/\* \*/.class
48+
49+
help:
50+
@echo "DeathByCaptcha Java Unified SDK - Makefile"
51+
@echo ""
52+
@echo "Usage: make [target]"
53+
@echo ""
54+
@echo "Targets:"
55+
@echo " all - Build everything (default)"
56+
@echo " clean - Remove compiled files"
57+
@echo " lib - Compile core library classes"
58+
@echo " jar - Create JAR files"
59+
@echo " doc - Generate Javadoc"
60+
@echo " examples - Compile example files"
61+
@echo " package - Create distribution ZIP"
62+
@echo " help - Show this help message"
63+
@echo ""
64+
@echo "Note: For Maven users, use 'mvn clean install' instead"
65+

0 commit comments

Comments
 (0)