B4J Code Snippet Rename result.jar using #Macro or #CustomBuildAction

Method 1: rename existing jar
B4X:
#Macro: Title, Rename, ide://run?file=%COMSPEC%&Args=/c&Args=ren&Args=result.jar&Args=libget-non-ui.jar
You can also check if the file exists before rename
or you will get an error "The system cannot find the file specified." (Exit code 1)
B4X:
#Macro: Title, Rename, ide://run?file=%COMSPEC%&Args=/c&Args=IF+EXIST+result.jar&Args=ren&Args=result.jar&Args=libget-non-ui.jar

Method 2: keep result.jar but copy to Additional Libraries folder
B4X:
#CustomBuildAction: 2, %COMSPEC%, /c copy result.jar %ADDITIONAL%\..\B4X\libget-non-ui.jar

Method 3: build the jar without running
B4X:
#Macro: Title, Build only, ide://run?File=%B4X%\B4JBuilder.exe&Args=-Task%3DBuild&Args=-BaseFolder%3D..&Args=-Output%3Dlibget_non_ui
Note: dash or hyphen in the output filename resulted the filename back to result.jar
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Added Method 2, just copy the result.jar to another destination.
B4X:
#CustomBuildAction: 2, %COMSPEC%, /c copy result.jar %ADDITIONAL%\..\B4X\libget-non-ui.jar

Edit: Replaced C:\Windows\System32\cmd.exe with %COMSPEC%
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Added Method 3 to build the jar without running by using B4JBuilder.exe
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Added &Args=IF+EXIST+result.jar to check if the file exists or already renamed for Method 1.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…