@@ -7,6 +7,9 @@ if (!hasProperty('mainClass')) {
77 ext. mainClass = ' com.annimon.ownlang.Main'
88}
99
10+ ext. generatedJavaDir = " ${ rootProject.projectDir} /src/main/generatedJava"
11+ sourceSets. main. java. srcDirs + = project. generatedJavaDir
12+
1013repositories {
1114 jcenter()
1215}
@@ -20,6 +23,21 @@ buildscript {
2023 }
2124}
2225
26+ task generateJavaSources () {
27+ doLast {
28+ def source = """
29+ package com.annimon.ownlang;
30+ class Gen {
31+ public static final String BUILD_DATE = "${ new Date().format('YYMMdd')} ";
32+ }
33+ """
34+ def genFile = new File (" ${ project.generatedJavaDir} /com/annimon/ownlang/Gen.java" )
35+ genFile. getParentFile(). mkdirs()
36+ genFile. write(source)
37+ }
38+ }
39+ compileJava. dependsOn(generateJavaSources)
40+
2341task run (dependsOn : classes, type : JavaExec ) {
2442 main = project. mainClass
2543 classpath = sourceSets. main. runtimeClasspath
@@ -37,13 +55,14 @@ task runOptimizing(dependsOn: classes, type: JavaExec) {
3755
3856task dist (dependsOn : classes, type : Jar ) {
3957 from files(sourceSets. main. output. classesDir)
58+ from files(sourceSets. main. output. resourcesDir)
4059 from {configurations. compile. collect {zipTree(it)}}
41- from files(sourceSets. main. resources)
42- libsDirName = " $rootProject . projectDir /dist"
60+ destinationDir file(" $rootProject . projectDir /dist" )
4361
44- manifest {
45- attributes ' Main-Class' : project. mainClass
46- }
62+ manifest. attributes(
63+ ' Main-Class' : project. mainClass,
64+ ' Build-Date' : new Date (). format(' YYMMdd' )
65+ )
4766}
4867
4968task proguard (dependsOn : dist, type : proguard.gradle.ProGuardTask ) {
0 commit comments