feat: init commit
This commit is contained in:
62
.gitignore
vendored
62
.gitignore
vendored
@@ -1,54 +1,10 @@
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
replay_pid*
|
||||
|
||||
# ---> macOS
|
||||
# General
|
||||
build
|
||||
classes
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
.gradle
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
71
build.gradle
Normal file
71
build.gradle
Normal file
@@ -0,0 +1,71 @@
|
||||
apply plugin: 'java'
|
||||
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 'build'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven() { url 'https://maven.aliyun.com/repository/central' }
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.11.RELEASE")
|
||||
}
|
||||
}
|
||||
apply plugin: 'org.springframework.boot'
|
||||
springBoot {
|
||||
mainClass = jarManifestMainClass
|
||||
}
|
||||
|
||||
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}")
|
||||
}
|
||||
}
|
||||
}
|
||||
22
build.json
Normal file
22
build.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"project": {
|
||||
"name": "picocli-cli",
|
||||
"main": "me.hatter.demo.PicocliCli",
|
||||
"archiveName": "picocli-cli"
|
||||
},
|
||||
"application": false,
|
||||
"java": "1.8",
|
||||
"builder": {
|
||||
"name": "gradle",
|
||||
"version": "3.1"
|
||||
},
|
||||
"repo": {
|
||||
"dependencies": [
|
||||
"me.hatter:commons:3.0",
|
||||
"info.picocli:picocli:4.7.7"
|
||||
],
|
||||
"testDependencies": [
|
||||
"junit:junit:4.12"
|
||||
]
|
||||
}
|
||||
}
|
||||
38
src/main/java/me/hatter/demo/PicocliCli.java
Normal file
38
src/main/java/me/hatter/demo/PicocliCli.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package me.hatter.demo;
|
||||
|
||||
import picocli.CommandLine;
|
||||
import picocli.CommandLine.Command;
|
||||
import picocli.CommandLine.Option;
|
||||
import picocli.CommandLine.Parameters;
|
||||
import java.io.File;
|
||||
|
||||
@Command(name = "example",
|
||||
mixinStandardHelpOptions = true,
|
||||
version = "Picocli example 1.0")
|
||||
public class PicocliCli {
|
||||
|
||||
@Option(names = {"-v", "--verbose"},
|
||||
description = "Verbose mode. Helpful for troubleshooting. Multiple -v options increase the verbosity.")
|
||||
private boolean[] verbose = new boolean[0];
|
||||
|
||||
@Parameters(arity = "1..*", paramLabel = "FILE", description = "File(s) to process.")
|
||||
private File[] inputFiles;
|
||||
|
||||
public void run() {
|
||||
if (verbose.length > 0) {
|
||||
System.out.println(inputFiles.length + " files to process...");
|
||||
}
|
||||
if (verbose.length > 1) {
|
||||
for (File f : inputFiles) {
|
||||
System.out.println(f.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// By implementing Runnable or Callable, parsing, error handling and handling user
|
||||
// requests for usage help or version help can be done with one line of code.
|
||||
int exitCode = new CommandLine(new PicocliCli()).execute(args);
|
||||
System.exit(exitCode);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user