|
| 1 | +apply plugin: 'java' |
| 2 | +apply plugin: 'maven' |
| 3 | +apply plugin: 'application' |
| 4 | + |
| 5 | +group = 'cic.unb.ca' |
| 6 | +version = '4.0' |
| 7 | +description = """CICFlowMeterV4""" |
| 8 | + |
| 9 | +sourceCompatibility = 1.8 |
| 10 | +targetCompatibility = 1.8 |
| 11 | + |
| 12 | +repositories { |
| 13 | + mavenLocal() |
| 14 | + mavenCentral() |
| 15 | + maven { url "https://clojars.org/repo" } |
| 16 | +} |
| 17 | +dependencies { |
| 18 | + compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0' |
| 19 | + compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.25' |
| 20 | + compile group: 'org.jnetpcap', name: 'jnetpcap', version:'1.4.1' |
| 21 | + compile group: 'junit', name: 'junit', version:'4.12' |
| 22 | + compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.6' |
| 23 | + compile group: 'org.apache.commons', name: 'commons-math3', version:'3.5' |
| 24 | + compile group: 'commons-io', name: 'commons-io', version:'2.5' |
| 25 | + compile group: 'nz.ac.waikato.cms.weka', name: 'weka-stable', version:'3.6.14' |
| 26 | + // https://mvnrepository.com/artifact/org.jfree/jfreechart |
| 27 | + compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0' |
| 28 | + // https://mvnrepository.com/artifact/com.google.guava/guava |
| 29 | + compile group: 'com.google.guava', name: 'guava', version: '23.6-jre' |
| 30 | + // https://mvnrepository.com/artifact/org.apache.tika/tika-core |
| 31 | + compile group: 'org.apache.tika', name: 'tika-core', version: '1.17' |
| 32 | + |
| 33 | +} |
| 34 | +sourceSets { |
| 35 | + main { |
| 36 | + java { |
| 37 | + srcDir 'src' |
| 38 | + exclude '**/CICFlowMeter.java' |
| 39 | + } |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +task zipSrc(type: Zip){ |
| 44 | + baseName "${applicationName}-Source" |
| 45 | + destinationDir = file('build/') |
| 46 | + from('.'){ |
| 47 | + include '**/' |
| 48 | + exclude '.gradle/','build/','bin/','logs/','*.iml','*.ipr','*.iws','.idea/','out/','data/' |
| 49 | + into "${applicationName}V${version}-Src" |
| 50 | + } |
| 51 | +} |
| 52 | + |
| 53 | +import org.apache.tools.ant.DirectoryScanner |
| 54 | +task zipPro(type: Zip){ |
| 55 | + |
| 56 | + doFirst { |
| 57 | + DirectoryScanner.defaultExcludes.each { DirectoryScanner.removeDefaultExclude it } |
| 58 | + //DirectoryScanner.addDefaultExclude 'something has to be in here or everything gets excluded' |
| 59 | + } |
| 60 | + |
| 61 | + doLast { |
| 62 | + DirectoryScanner.resetDefaultExcludes() |
| 63 | + } |
| 64 | + |
| 65 | + baseName "${applicationName}-Full" |
| 66 | + destinationDir = file('build/') |
| 67 | + |
| 68 | + from('.'){ |
| 69 | + include '**/' |
| 70 | + exclude '.gradle/','build/','bin/','logs/','*.iml','*.ipr','*.iws','.idea/','out/','data/',".git/" |
| 71 | + into "${applicationName}V${version}" |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | + |
| 76 | +task fatJar(type: Jar) { |
| 77 | + println 'type Jar' |
| 78 | + |
| 79 | + manifest { |
| 80 | + |
| 81 | + attributes 'Premain-Class': 'swing.common.ObjectSizeFetcher' |
| 82 | + attributes 'Can-Retransform-Classes': true |
| 83 | + attributes 'Implementation-Title': 'Gradle Jar File Example', |
| 84 | + 'Implementation-Version': version, |
| 85 | + 'Main-Class': 'cic.cs.unb.ca.ifm.App' |
| 86 | + |
| 87 | + } |
| 88 | + /*baseName = "NetWorkTraffic" + '-all' |
| 89 | + from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } |
| 90 | + into(new File('build/jar/')) |
| 91 | + with jar*/ |
| 92 | +} |
| 93 | + |
| 94 | + |
| 95 | +task execute(type: JavaExec) { |
| 96 | + println 'type JavaExec' |
| 97 | + |
| 98 | + |
| 99 | + main = "cic.cs.unb.ca.ifm.App" //main class |
| 100 | + classpath = sourceSets.main.runtimeClasspath |
| 101 | + String osName = System.getProperty('os.name').toLowerCase() |
| 102 | + if(osName.contains('windows')){ |
| 103 | + jvmArgs '-Djava.library.path=jnetpcap/win/jnetpcap-1.4.r1425' |
| 104 | + }else{ |
| 105 | + jvmArgs '-Djava.library.path=jnetpcap/linux/jnetpcap-1.4.r1425' |
| 106 | + } |
| 107 | +} |
| 108 | + |
| 109 | + |
| 110 | +task exeCMD(type: JavaExec){ |
| 111 | + main = "cic.cs.unb.ca.ifm.Cmd" //main class |
| 112 | + classpath = sourceSets.main.runtimeClasspath |
| 113 | + String osName = System.getProperty('os.name').toLowerCase() |
| 114 | + if(osName.contains('windows')){ |
| 115 | + jvmArgs '-Djava.library.path=jnetpcap/win/jnetpcap-1.4.r1425' |
| 116 | + }else{ |
| 117 | + jvmArgs '-Djava.library.path=jnetpcap/linux/jnetpcap-1.4.r1425' |
| 118 | + } |
| 119 | + //args = ["/home/yzhang29/0a/Capture/", "/home/yzhang29/0a/Capture/out/"] |
| 120 | +} |
| 121 | + |
| 122 | + |
| 123 | +task cmdScript(type: CreateStartScripts) { |
| 124 | + mainClassName = "cic.cs.unb.ca.ifm.Cmd" |
| 125 | + applicationName = "cfm" |
| 126 | + outputDir = new File(project.buildDir, 'scripts') |
| 127 | + classpath = jar.outputs.files + project.configurations.runtime |
| 128 | + defaultJvmOpts = ["-Djava.library.path=../lib/native"] |
| 129 | +} |
| 130 | + |
| 131 | +applicationDistribution.into("bin") { |
| 132 | + from(cmdScript) |
| 133 | + fileMode = 0755 |
| 134 | +} |
| 135 | + |
| 136 | + |
| 137 | +// The Application Plugin |
| 138 | +mainClassName = "cic.cs.unb.ca.ifm.App" |
| 139 | +applicationName = "CICFlowMeter" |
| 140 | +applicationDefaultJvmArgs = ["-Djava.library.path=../lib/native"] |
| 141 | + |
| 142 | +applicationDistribution.from("jnetpcap/linux/jnetpcap-1.4.r1425") { |
| 143 | + include "*.so" |
| 144 | + into('lib/native') |
| 145 | +} |
| 146 | +applicationDistribution.from("jnetpcap/win/jnetpcap-1.4.r1425") { |
| 147 | + include "*.dll" |
| 148 | + into('lib/native') |
| 149 | +} |
| 150 | +applicationDistribution.from('LICENSE.txt'){ |
| 151 | + into('') |
| 152 | +} |
| 153 | +applicationDistribution.from('ReadMe.txt'){ |
| 154 | + into('') |
| 155 | + rename("ReadMe.txt","README.md") |
| 156 | +} |
0 commit comments