After creating a simple module without UI in Java, place it in the execution environment.
・ Eclipse ・ Gradle
ʻAdd the application` plugin and the definition of the Main classpath.
build.gradle
apply plugin: 'application'
mainClassName = 'jp.vicugna_pacos.admainte.main.AdMainteMain'
project folder / build / install
. Copy it and move it to the specified location.bin
folder is the startup script.Looking at the bat file created above, it is assumed that the environment variable JAVA_HOME
is defined.
If there is no JAVA_HOME
, create a wrapper bat file as follows.
Wrapper bat sample
@echo off
setlocal
set ARGS=%*
set DIRNAME=%~dp0
set BATNAME=%DIRNAME%AD_MAINTE\bin\AD_MAINTE.bat
set JAVA_HOME=E:\jre\8
%BATNAME% %ARGS%
endlocal
First, put the files you want to go out in the src / dist
folder.
As it is, the property file in src / main / resources
has priority, so do not include it in the Jar file.
build.gradle
jar {
exclude '**/config.properties'
exclude '**/logback.xml'
}
In addition, the files placed in the dist
folder should be included in the classpath at runtime.
build.gradle
startScripts {
classpath += files('src/dist/XxxAPlaceHolderForAConfigxxX')
doLast {
def windowsScriptFile = file getWindowsScript()
def unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replace('%APP_HOME%\\lib\\XxxAPlaceHolderForAConfigxxX', '%APP_HOME%\\config')
unixScriptFile.text = unixScriptFile.text.replace('$APP_HOME/lib/XxxAPlaceHolderForAConfigxxX', '$APP_HOME/config')
}
}
In this sample, the files placed in the dist / config
folder will be included in the classpath.
reference: java - Adding classpath entries using Gradle's Application plugin - Stack Overflow https://stackoverflow.com/questions/10518603/adding-classpath-entries-using-gradles-application-plugin
Recommended Posts