view build.gradle @ 557:07bc0bf4b21a

fix build.gradle
author riono
date Thu, 30 Jan 2020 17:26:01 +0900
parents ff4c1972aa2e
children 8e507ce09187
line wrap: on
line source

plugins {
    id "edu.sc.seis.macAppBundle" version "2.3.0"
}

apply plugin:'java'
apply plugin: 'eclipse'
apply plugin: 'application'
apply plugin: "edu.sc.seis.macAppBundle"


sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
version = '2.7.2'

project.ext.baseName = 'tightvnc-jviewer'
def buildNo = processBuildNo(version)

defaultTasks 'clean' , 'jar'
macAppBundle {
    mainClassName = "com.glavsoft.viewer.TreeViewer"
    icon = "src/viewer_swing/resources/TreeVNC.png.icns"
    bundleJRE = true
    javaProperties.put("apple.laf.useScreenMenuBar", "true")
}

//convasion jar file for .app
//https://github.com/crotwell/gradle-macappbundle/wiki/Intro
//icon create web applecation
//https://iconverticons.com/online/ 
configurations {
    viewerSwingImplementation { extendsFrom implementation }
    //viewerSwingRuntime { extendsFrom viewerSwingCompile, runtime }
}

sourceSets {
	viewerSwing {
		java {
			srcDir 'src/viewer_swing/java'
		}
		resources {
			srcDir 'src/viewer_swing/resources'
		}
	}
	main {
		java.srcDirs += viewerSwing.java.srcDirs
		resources.srcDirs += viewerSwing.resources.srcDirs
	}
}

repositories {
	flatDir {
		dirs 'src/libs/'
	}
}

dependencies {
    viewerSwingImplementation group: 'com.jcraft', name: 'jsch', version: '0.1.+', ext: 'jar'
    implementation group: 'com.jcraft', name: 'jsch', version: '0.1.+', ext: 'jar'
    //viewerSwingRuntime configurations.viewerSwingCompile
}

def manifestAttributes = ['Main-Class': 'com.glavsoft.viewer.TreeViewer',
        'Implementation-Version': "${project.version} (${buildNo})",
        'Implementation-Title': 'TightVNC Viewer',
        'Implementation-Vendor': 'GlavSoft LLC.']

jar {
    //baseName = project.baseName
    //version = null
    manifest {
        attributes manifestAttributes
    }
//    def runtimeDeps = configurations.viewerSwingRuntime.collect {
//        it.isDirectory() ? it : zipTree(it)
//    }
//    from(runtimeDeps) {
//        exclude 'META-INF/**'
//    }
}




task noSshJar (type: Jar, dependsOn: classes) {
//    baseName = 'nossh/' + project.baseName
//    version = null
    manifest {
        attributes manifestAttributes
    }
    from sourceSets.main.output
}

//artifacts {
//    archives file('src/web/viewer-applet-example.html')
//    archives noSshJar
//}

//uploadArchives {
//    repositories {
//
//    }
//	uploadDescriptor = false
//}

//task dist(dependsOn: uploadArchives)

def processBuildNo(currentVersion) {
    final String VERSION = 'version'
    final String BUILD = 'build'

    def lastVersion = currentVersion
    def lastBuild = 0
    def buildNoFile = new File('.build_no')
    if ( ! buildNoFile.exists()) {
        buildNoFile.createNewFile()
        buildNoFile << "${VERSION}=${lastVersion}\n${BUILD}=${lastBuild}"
    }
    def versions = [:]
    buildNoFile.eachLine {
        def splitted = it.split('=')
        if (splitted.size() == 2) {
            def (key, value) = splitted
            switch(key.trim()) {
                case VERSION:
                    lastVersion = value.trim()
                    break
                case BUILD:
                    try {
                        lastBuild = value != null ? value.trim() as Integer : 0
                    } catch (NumberFormatException) {}
                    versions[lastVersion] = lastBuild
                    break
            }
        }
    }
    lastVersion = versions[currentVersion]
    if (null == lastVersion) {
        versions[currentVersion] = 0
    }
    ++versions[currentVersion]
    def outString = ''
    versions.each { v, b ->
        outString += "${VERSION}=${v}\n${BUILD}=${b}\n\n"
    }
    buildNoFile.write(outString)
    versions[currentVersion]
}

// set mainclass to Application Plugin
mainClassName = 'com.glavsoft.viewer.TreeViewer'
applicationName = 'TreeVNC'

//allprojects {
//    gradle.projectsEvaluated {
//        tasks.withType(JavaCompile) {
//            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
//        }
//    }
//}