forked from micronaut-projects/micronaut-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
103 lines (93 loc) · 3.44 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
repositories {
jcenter()
mavenCentral()
}
dependencies {
compile "info.picocli:picocli:$picocliVersion"
compile "org.apache.ant:ant:1.9.7"
compile dependencyModuleVersion("groovy", "groovy-ant")
compile dependencyModuleVersion("groovy", "groovy-json")
compile dependencyModuleVersion("groovy", "groovy-jmx")
compile dependencyModuleVersion("groovy", "groovy-xml")
compile dependencyModuleVersion("groovy", "groovy-templates")
compile "org.fusesource.jansi:jansi:1.14"
compile "jline:jline:2.12"
compile "org.springframework.boot:spring-boot-cli:1.5.10.RELEASE"
compile dependencyVersion("snakeyaml")
runtime dependencyModuleVersion("slf4j", "slf4j-simple")
runtime "org.codehaus.plexus:plexus-component-api:1.0-alpha-33"
testCompile "net.sf.expectit:expectit-core:0.5.0"
testCompile "com.github.jnr:jnr-posix:3.0.6"
}
File outDir = new File(project.buildDir, 'bin')
task createStartScripts(type: MicronautCreateStartScripts) {
description = "Creates OS specific scripts to run the Micronaut CLI."
mainClassName = 'io.micronaut.cli.MicronautCli'
applicationName = 'mn'
defaultJvmOpts = ["-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-XX:CICompilerCount=3"]
outputDir = outDir
classpath = configurations.runtime
doLast {
ant.chmod(file: new File(outDir, 'mn'), perm: 'ugo+rx')
copy {
from 'src/main/resources/mn_completion'
into outDir
}
}
}
class MicronautCreateStartScripts extends org.gradle.api.tasks.application.CreateStartScripts {
Collection<String> projectArtifacts=[]
@org.gradle.api.tasks.TaskAction
void generate() {
def generator = new org.gradle.api.internal.plugins.StartScriptGenerator()
generator.unixStartScriptGenerator.template = project.resources.text.fromFile('src/main/resources/unixStartScript.txt')
generator.applicationName = getApplicationName()
generator.mainClassName = getMainClassName()
generator.defaultJvmOpts = getDefaultJvmOpts()
generator.optsEnvironmentVar = getOptsEnvironmentVar()
generator.exitEnvironmentVar = getExitEnvironmentVar()
generator.classpath = project.tasks.getByName('fatJar').outputs.files.collect { it.name }
generator.scriptRelPath = "bin/${getUnixScript().name}"
generator.generateUnixScript(getUnixScript())
generator.generateWindowsScript(getWindowsScript())
}
}
configurations.all {
resolutionStrategy {
// prevent fatJar result containing multiple versions of picocli
force("info.picocli:picocli:$picocliVersion")
}
}
task fatJar(type: Jar, dependsOn: ['createStartScripts']) {
manifest {
attributes 'Main-Class': 'io.micronaut.cli.MicronautCli',
'Implementation-Version': project.version
}
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
destinationDir = project.buildDir
}
task cliZip(type: Zip, dependsOn: ['fatJar']) {
archiveName = "micronaut-${project.version}.zip"
into("micronaut-${project.version}") {
from('build/bin') {
into('bin')
}
from('../media') {
into('media')
}
from fatJar.outputs.files
from('../LICENSE')
}
}
publishing {
publications {
maven(MavenPublication) {
artifact cliZip {
classifier "dist"
}
}
}
}