|
| 1 | +/* |
| 2 | +* Packs metadata generator in a .tgz file in ~/dist folder |
| 3 | +* To build .tgz |
| 4 | +* gradlew packmg |
| 5 | +* To build jar |
| 6 | +* gradlew jarmg |
| 7 | +*/ |
| 8 | +apply plugin: "java" |
| 9 | + |
| 10 | +sourceCompatibility = 1.6 |
| 11 | +targetCompatibility = 1.6 |
| 12 | + |
| 13 | +def isWinOs = System.properties['os.name'].toLowerCase().contains('windows') |
| 14 | + |
| 15 | +buildscript { |
| 16 | + repositories { |
| 17 | + jcenter() |
| 18 | + } |
| 19 | + |
| 20 | + dependencies { |
| 21 | + classpath 'com.android.tools.build:gradle:1.5.0' |
| 22 | + } |
| 23 | +} |
| 24 | + |
| 25 | +sourceSets { |
| 26 | + main { |
| 27 | + java { |
| 28 | + srcDir 'src/src' |
| 29 | + } |
| 30 | + } |
| 31 | + main.output.classesDir = "$rootDir/dist/classes" |
| 32 | +} |
| 33 | + |
| 34 | +dependencies { |
| 35 | + compile files("./src/libs/bcel-5.2.jar") |
| 36 | +} |
| 37 | + |
| 38 | +task makeDistDir { |
| 39 | + def distDir = new File("$rootDir/dist") |
| 40 | + distDir.mkdirs() |
| 41 | +} |
| 42 | + |
| 43 | +task cleanDist (type: Delete) { |
| 44 | + delete "$rootDir/dist" |
| 45 | +} |
| 46 | + |
| 47 | +task cleanDistForJar (type: Delete) { |
| 48 | + delete "$rootDir/dist" |
| 49 | +} |
| 50 | + |
| 51 | +task cleanBuildDir (type: Delete){ |
| 52 | + delete "$rootDir/build" |
| 53 | +} |
| 54 | + |
| 55 | +task cleanBuildDirForJar (type: Delete){ |
| 56 | + delete "$rootDir/build" |
| 57 | +} |
| 58 | + |
| 59 | +task cleanBin (type: Delete) { |
| 60 | + delete "$rootDir/src/bin" |
| 61 | +} |
| 62 | + |
| 63 | +task copyNecessaryFiles { |
| 64 | + doLast { |
| 65 | + copy { |
| 66 | + from "$rootDir/helpers" |
| 67 | + into "$rootDir/dist/bin" |
| 68 | + } |
| 69 | + |
| 70 | + copy { |
| 71 | + from "$rootDir/package.json" |
| 72 | + into "$rootDir/dist" |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +task packMetadataGenerator (type: Exec) { |
| 78 | + workingDir "$rootDir/dist" |
| 79 | + |
| 80 | + if(isWinOs) { |
| 81 | + commandLine "cmd", "/c", "npm", "pack" |
| 82 | + } |
| 83 | + else { |
| 84 | + commandLine "npm", "pack" |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +jar { |
| 89 | + manifest { |
| 90 | + attributes("Manifest-Version": "1.0", |
| 91 | + "Main-Class": "com.telerik.metadata.Generator") |
| 92 | + } |
| 93 | + |
| 94 | + from { |
| 95 | + |
| 96 | + configurations.runtime.collect { |
| 97 | + it.isDirectory() ? it : zipTree(it) |
| 98 | + } |
| 99 | + |
| 100 | + configurations.compile.collect { |
| 101 | + it.isDirectory() ? it : zipTree(it) |
| 102 | + } |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +task copyJarToDist (type: Copy) { |
| 107 | + from "$rootDir/build/libs/android-metadata-generator.jar" |
| 108 | + into "$rootDir/dist" |
| 109 | +} |
| 110 | + |
| 111 | +makeDistDir.dependsOn(cleanDist) |
| 112 | +cleanBin.dependsOn(makeDistDir) |
| 113 | +compileJava.dependsOn(cleanBin) |
| 114 | +cleanBuildDir.dependsOn(compileJava) |
| 115 | +copyNecessaryFiles.dependsOn(cleanBuildDir) |
| 116 | +packMetadataGenerator.dependsOn(copyNecessaryFiles) |
| 117 | + |
| 118 | +task packmg { |
| 119 | + dependsOn packMetadataGenerator |
| 120 | +} |
| 121 | + |
| 122 | +cleanDistForJar.dependsOn(jar) |
| 123 | +copyJarToDist.dependsOn(cleanDistForJar) |
| 124 | +cleanBuildDirForJar.dependsOn(copyJarToDist) |
| 125 | + |
| 126 | +task jarmg { |
| 127 | + dependsOn cleanBuildDirForJar |
| 128 | +} |
| 129 | + |
| 130 | + |
0 commit comments