From ee50f598e0f9210442772f28182ca7d4eba1a27a Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 20 May 2023 12:22:19 +0800 Subject: [PATCH] feat: yubikey-ca-java --- README.md | 2 +- yubikey-ca-java/.gitignore | 10 +++ yubikey-ca-java/build.gradle | 100 +++++++++++++++++++++++++ yubikey-ca-java/build.json | 21 ++++++ Cargo.lock => yubikey-ca-rs/Cargo.lock | 0 Cargo.toml => yubikey-ca-rs/Cargo.toml | 0 {src => yubikey-ca-rs/src}/main.rs | 0 7 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 yubikey-ca-java/.gitignore create mode 100644 yubikey-ca-java/build.gradle create mode 100644 yubikey-ca-java/build.json rename Cargo.lock => yubikey-ca-rs/Cargo.lock (100%) rename Cargo.toml => yubikey-ca-rs/Cargo.toml (100%) rename {src => yubikey-ca-rs/src}/main.rs (100%) diff --git a/README.md b/README.md index b139c32..7028565 100644 --- a/README.md +++ b/README.md @@ -9,5 +9,5 @@ Yubikey CA Tool Reference: * https://github.com/obelisk/sshcerts * https://github.com/obelisk/rustica - +* https://git.hatter.ink/hatter/card-cli diff --git a/yubikey-ca-java/.gitignore b/yubikey-ca-java/.gitignore new file mode 100644 index 0000000..94b7950 --- /dev/null +++ b/yubikey-ca-java/.gitignore @@ -0,0 +1,10 @@ +build +classes +.DS_Store +.gradle +.classpath +.project +.settings +*.iml +*.ipr +*.iws \ No newline at end of file diff --git a/yubikey-ca-java/build.gradle b/yubikey-ca-java/build.gradle new file mode 100644 index 0000000..41d4796 --- /dev/null +++ b/yubikey-ca-java/build.gradle @@ -0,0 +1,100 @@ +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' + +def JsonSlurper = Class.forName('groovy.json.JsonSlurper'); +def buildJSON = JsonSlurper.newInstance().parseText(new File("build.json").text) + +if (buildJSON.application) { apply plugin: 'application' } + +def baseProjectName = buildJSON?.project?.name ?: '__project_name__'; +def shellCommandName = baseProjectName +def eclipseProjectName = baseProjectName +def eclipseProjectComment = buildJSON?.project?.comment ?: '__project_name_comment__' +def jarManifestMainClass = buildJSON?.project?.main ?: 'SampleMain' + +if (buildJSON.application) { mainClassName = jarManifestMainClass } +archivesBaseName = buildJSON?.project?.archiveName ?: baseProjectName +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +def addRepo = new File(System.getProperty("user.home"), ".build_add.repo") + +repositories { + mavenLocal() + // mavenCentral() + maven() { url 'https://maven.aliyun.com/repository/central' } + if (addRepo.exists()) { maven() { url addRepo.text.trim() } } +} + +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + +// '-x test' skip unit test +defaultTasks 'packjar' + +task packjarsrc << { + ant.jar(destfile: "${baseProjectName}-sources.jar") { + fileset(dir: 'src/main/java', includes: '**/*.java') + } +} +packjarsrc.dependsOn build + +task packjar << { + def packtempclasses = "packtempclasses" + def libs = ant.path { + fileset(dir: 'build/libs', includes: '*.jar') + } + libs.list().each { + ant.unzip(dest: packtempclasses, src: it) + } + new File(packtempclasses + "/jar-version-build.txt").write(new Date().format("yyyyMMdd"), "UTF-8") + ant.jar(destfile: "${baseProjectName}.jar") { + fileset(dir: packtempclasses, includes: '**/*.*') + } + ant.delete(dir: packtempclasses) +} +packjar.dependsOn packjarsrc + +dependencies { + compile files(fileTree(dir: 'lib', includes: ['*.jar'], excludes: ['*-sources.jar', '*-javadoc.jar'])) + + if (buildJSON.repo != null && buildJSON.repo.dependencies != null) { + buildJSON.repo.dependencies.each { + compile("${it}") + } + } + if (buildJSON.repo != null && buildJSON.repo.testDependencies != null) { + buildJSON.repo.testDependencies.each { + testCompile("${it}") + } + } +} + +eclipse { + project { + name = eclipseProjectName + comment = eclipseProjectComment + } + classpath { + defaultOutputDir = file('classes') + downloadSources = true + file { + whenMerged { classpath -> + classpath.entries.findAll { it.kind=='lib' }.each { + if ((it.path != null) && (it.sourcePath == null) && file(it.path.replace(".jar", "-sources.jar")).exists()) { + it.sourcePath = getFileReferenceFactory().fromPath(it.path.replace(".jar", "-sources.jar")) + } + } + } + } + } +} + +eclipseJdt << { + File f = file('.settings/org.eclipse.core.resources.prefs') + f.write('eclipse.preferences.version=1\n') + f.append('encoding/=utf-8') +} + diff --git a/yubikey-ca-java/build.json b/yubikey-ca-java/build.json new file mode 100644 index 0000000..617cfe6 --- /dev/null +++ b/yubikey-ca-java/build.json @@ -0,0 +1,21 @@ +{ + "project": { + "name": "yubikey-ca-java", + "main": "SampleMain", + "archiveName": "yubikey-ca-java" + }, + "application": false, + "java": "1.8", + "builder": { + "name": "gradle", + "version": "3.1" + }, + "repo": { + "dependencies": [ + "me.hatter:commons:3.0" + ], + "testDependencies": [ + "junit:junit:4.12" + ] + } +} diff --git a/Cargo.lock b/yubikey-ca-rs/Cargo.lock similarity index 100% rename from Cargo.lock rename to yubikey-ca-rs/Cargo.lock diff --git a/Cargo.toml b/yubikey-ca-rs/Cargo.toml similarity index 100% rename from Cargo.toml rename to yubikey-ca-rs/Cargo.toml diff --git a/src/main.rs b/yubikey-ca-rs/src/main.rs similarity index 100% rename from src/main.rs rename to yubikey-ca-rs/src/main.rs