Jump to content

[SOLVED] am i able to create 3 jars (one for each os linux64, mac, win32)


Recommended Posts

Posted (edited)

Hello i have a very heavy dependency in my mod (about 150 mb in size) but i am able to shrink it to 51 mb if i will make diffrent jars for diffrent os'es now how do i automate this because i arelady know how to just dumbly put selected jars into my output jar

Edited by lukas2005
Posted

Solved this by adding this to my build.gradle (at the end)

Spoiler
// Custom tasks
task makeTmpWin32(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'mkdir', 'tmp']
}
task unpackModWin32(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\build\\libs\\'+archivesBaseName+'-'+version+'.jar']
}
task makeTmpMac(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'mkdir', 'tmp']
}
task unpackModMac(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\build\\libs\\'+archivesBaseName+'-'+version+'.jar']
}
task makeTmpLinux64(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'mkdir', 'tmp']
}
task unpackModLinux64(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\build\\libs\\'+archivesBaseName+'-'+version+'.jar']
}
task unpackLibWin32(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\libs\\jxbrowser\\lib\\jxbrowser-win32-'+jxbrowser_version+'.jar']
}
task unpackLibMac(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\libs\\jxbrowser\\lib\\jxbrowser-mac-'+jxbrowser_version+'.jar']
}
task unpackLibLinux64(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-xvf', '..\\libs\\jxbrowser\\lib\\jxbrowser-linux64-'+jxbrowser_version+'.jar']
}
task repackWin32(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-cvf',  '..\\build\\'+archivesBaseName+'-'+version+'-win32.jar', '.']
}
task repackMac(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-cvf',  '..\\build\\'+archivesBaseName+'-'+version+'-mac.jar', '.']
}
task repackLinux64(type:Exec) {
 workingDir = 'tmp'
 commandLine = ['cmd.exe', '/c', 'jar', '-cvf',  '..\\build\\'+archivesBaseName+'-'+version+'-linux64.jar', '.']
}
task removeTmpWin32(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'rmdir', '/S', '/Q','tmp']
}
task removeTmpMac(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'rmdir', '/S', '/Q','tmp']
}
task removeTmpLinux64(type:Exec) {
 commandLine = ['cmd.exe', '/c', 'rmdir', '/S', '/Q','tmp']
}
task packageWin32() {
 dependsOn makeTmpWin32
 dependsOn unpackModWin32
 dependsOn unpackLibWin32
 dependsOn repackWin32
 dependsOn removeTmpWin32
 
 tasks.findByName('unpackModWin32').mustRunAfter 'makeTmpWin32'
 tasks.findByName('unpackLibWin32').mustRunAfter 'unpackModWin32'
 tasks.findByName('repackWin32').mustRunAfter 'unpackLibWin32'
 tasks.findByName('removeTmpWin32').mustRunAfter 'repackWin32'
}
task packageMac() {
 dependsOn makeTmpMac
 dependsOn unpackModMac
 dependsOn unpackLibMac
 dependsOn repackMac
 dependsOn removeTmpMac
 
 tasks.findByName('unpackModMac').mustRunAfter 'makeTmpMac'
 tasks.findByName('unpackLibMac').mustRunAfter 'unpackModMac'
 tasks.findByName('repackMac').mustRunAfter 'unpackLibMac'
 tasks.findByName('removeTmpMac').mustRunAfter 'repackMac'
}
task packageLinux64() {
 dependsOn makeTmpLinux64
 dependsOn unpackModLinux64
 dependsOn unpackLibLinux64
 dependsOn repackLinux64
 dependsOn removeTmpLinux64
 
 tasks.findByName('unpackModLinux64').mustRunAfter 'makeTmpLinux64'
 tasks.findByName('unpackLibLinux64').mustRunAfter 'unpackModLinux64'
 tasks.findByName('repackLinux64').mustRunAfter 'unpackLibLinux64'
 tasks.findByName('removeTmpLinux64').mustRunAfter 'repackLinux64'
}
task buildAll() {
 dependsOn build
 dependsOn packageWin32
 dependsOn packageMac
 dependsOn packageLinux64
 
 tasks.findByName('packageWin32').mustRunAfter 'build'
 tasks.findByName('packageMac').mustRunAfter 'packageWin32'
 tasks.findByName('packageLinux64').mustRunAfter 'packageMac'
}

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.