First commit.
This commit is contained in:
commit
99250cc9cb
16 changed files with 201 additions and 0 deletions
5
.gitattributes
vendored
Normal file
5
.gitattributes
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# batch files are specific to windows and always crlf
|
||||
*.bat eol=crlf
|
28
.gitignore
vendored
Normal file
28
.gitignore
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
**/.idea/dictionaries
|
||||
**/.idea/gradle.xml
|
||||
**/.idea/libraries
|
||||
**/.idea/tasks.xml
|
||||
**/.idea/workspace.xml
|
||||
*.iws
|
||||
.classpath
|
||||
.DS_Store
|
||||
.gradle
|
||||
.kobalt
|
||||
.nb-gradle
|
||||
.project
|
||||
.settings
|
||||
/bin
|
||||
/build
|
||||
/deploy
|
||||
/dist
|
||||
/gen
|
||||
/gradle.properties
|
||||
/local.properties
|
||||
/out
|
||||
/proguard-project.txt
|
||||
/project.properties
|
||||
/target
|
||||
/test-output
|
||||
ehthumbs.db
|
||||
kobaltBuild
|
||||
Thumbs.db
|
BIN
kobalt-1.0.58-sources.jar
Normal file
BIN
kobalt-1.0.58-sources.jar
Normal file
Binary file not shown.
BIN
kobalt-1.0.58.jar
Normal file
BIN
kobalt-1.0.58.jar
Normal file
Binary file not shown.
22
kobalt/Build.kt.iml
Normal file
22
kobalt/Build.kt.iml
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Build.kt" external.linked.project.path="$MODULE_DIR$/.." external.root.project.path="$MODULE_DIR$/.." external.system.id="KOBALT" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/out/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/out/test-classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="Kobalt: com.beust.kobalt:kobalt:jar:1.0.59">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.kobalt/wrapper/dist/kobalt-1.0.59/kobalt/wrapper/kobalt-1.0.59.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
47
kobalt/src/Build.kt
Normal file
47
kobalt/src/Build.kt
Normal file
|
@ -0,0 +1,47 @@
|
|||
|
||||
import com.beust.kobalt.buildScript
|
||||
import com.beust.kobalt.plugin.application.application
|
||||
import com.beust.kobalt.plugin.packaging.assemble
|
||||
import com.beust.kobalt.project
|
||||
|
||||
val bs = buildScript {
|
||||
repos()
|
||||
}
|
||||
|
||||
|
||||
val p = project {
|
||||
|
||||
name = "fatjar"
|
||||
group = "com.example"
|
||||
artifactId = name
|
||||
version = "0.1"
|
||||
|
||||
sourceDirectories {
|
||||
path("src/main/kotlin")
|
||||
}
|
||||
|
||||
sourceDirectoriesTest {
|
||||
path("src/test/kotlin")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile("org.apache.commons:commons-compress:1.13")
|
||||
compile("commons-io:commons-io:2.5")
|
||||
}
|
||||
|
||||
dependenciesTest {
|
||||
compile("org.testng:testng:6.11")
|
||||
|
||||
}
|
||||
|
||||
assemble {
|
||||
jar {
|
||||
}
|
||||
}
|
||||
|
||||
application {
|
||||
mainClass = "com.example.MainKt"
|
||||
}
|
||||
|
||||
|
||||
}
|
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
BIN
kobalt/wrapper/kobalt-wrapper.jar
Normal file
Binary file not shown.
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
1
kobalt/wrapper/kobalt-wrapper.properties
Normal file
|
@ -0,0 +1 @@
|
|||
kobalt.version=1.0.59
|
2
kobaltw
Normal file
2
kobaltw
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env sh
|
||||
java -jar "`dirname "$0"`/kobalt/wrapper/kobalt-wrapper.jar" $*
|
4
kobaltw.bat
Normal file
4
kobaltw.bat
Normal file
|
@ -0,0 +1,4 @@
|
|||
@echo off
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
java -jar "%DIRNAME%/kobalt/wrapper/kobalt-wrapper.jar" %*
|
BIN
lib/kotlin-reflect.jar
Normal file
BIN
lib/kotlin-reflect.jar
Normal file
Binary file not shown.
BIN
lib/kotlin-runtime-sources.jar
Normal file
BIN
lib/kotlin-runtime-sources.jar
Normal file
Binary file not shown.
BIN
lib/kotlin-runtime.jar
Normal file
BIN
lib/kotlin-runtime.jar
Normal file
Binary file not shown.
BIN
libs/fatjar-0.1.jar
Normal file
BIN
libs/fatjar-0.1.jar
Normal file
Binary file not shown.
84
src/main/kotlin/com/example/Main.kt
Normal file
84
src/main/kotlin/com/example/Main.kt
Normal file
|
@ -0,0 +1,84 @@
|
|||
package com.example
|
||||
|
||||
import org.apache.commons.compress.archivers.zip.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
internal var allFilesPredicate: ZipArchiveEntryPredicate = ZipArchiveEntryPredicate { true }
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val kobalt = File("kobalt-1.0.58.jar")
|
||||
val zip = File("kobalt-1.0.58.zip")
|
||||
val src = File("kobalt-1.0.58-sources.jar")
|
||||
|
||||
//rezip2(kobalt, zip)
|
||||
rezip3(kobalt, src, zip)
|
||||
}
|
||||
|
||||
fun rezip(jarIn: File, zipOut: File) {
|
||||
val s = System.currentTimeMillis()
|
||||
val zos = ZipArchiveOutputStream(zipOut)
|
||||
zos.encoding = "UTF-8"
|
||||
val zip = ZipFile(jarIn)
|
||||
zip.copyRawEntries(zos, allFilesPredicate)
|
||||
zos.close()
|
||||
zip.close()
|
||||
|
||||
println("Rezip Time: " + (System.currentTimeMillis() - s) + "ms")
|
||||
}
|
||||
|
||||
fun rezip2(jarIn: File, zipOut: File) {
|
||||
val s = System.currentTimeMillis()
|
||||
val zos = ZipArchiveOutputStream(zipOut)
|
||||
zos.encoding = "UTF-8"
|
||||
val zip = ZipFile(jarIn)
|
||||
|
||||
for (entry in zip.entries) {
|
||||
zos.addRawArchiveEntry(entry, zip.getRawInputStream(entry))
|
||||
}
|
||||
|
||||
zos.close()
|
||||
|
||||
zip.close()
|
||||
|
||||
println("Rezip2 Time: " + (System.currentTimeMillis() - s) + "ms")
|
||||
}
|
||||
|
||||
fun rezip3(jarIn: File, srcJar: File, zipOut: File) {
|
||||
val s = System.currentTimeMillis()
|
||||
val zos = ZipArchiveOutputStream(zipOut)
|
||||
zos.encoding = "UTF-8"
|
||||
val jar = ZipFile(jarIn)
|
||||
|
||||
val jarEntries = jar.entries
|
||||
|
||||
for (entry in jar.entries) {
|
||||
zos.addRawArchiveEntry(entry, jar.getRawInputStream(entry))
|
||||
}
|
||||
|
||||
jar.close()
|
||||
|
||||
val src = ZipFile(srcJar)
|
||||
|
||||
for (entry in src.entries) {
|
||||
if (!entryExists(jarEntries, entry)) {
|
||||
zos.addRawArchiveEntry(entry, src.getRawInputStream(entry))
|
||||
}
|
||||
}
|
||||
|
||||
src.close()
|
||||
|
||||
zos.close()
|
||||
|
||||
println("Rezip3 Time: " + (System.currentTimeMillis() - s) + "ms")
|
||||
}
|
||||
|
||||
fun entryExists(jarEntries: Enumeration<ZipArchiveEntry>, entry: ZipArchiveEntry): Boolean {
|
||||
for (e in jarEntries) {
|
||||
if (e.name == entry.name) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
8
src/test/kotlin/com/example/MainTest.kt
Normal file
8
src/test/kotlin/com/example/MainTest.kt
Normal file
|
@ -0,0 +1,8 @@
|
|||
package com.example
|
||||
|
||||
import org.testng.annotations.Test
|
||||
|
||||
class ExampleTest {
|
||||
@Test
|
||||
fun f() = println("Running test")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue