Newer
Older
auth_project / build.gradle
plugins {
	id "application";
}

application {
	def defaultMainClass = "service.BasicAccessServer";
	mainClass = project.hasProperty("mainClass") ? project.getProperty("mainClass") : defaultMainClass;
}

repositories {
	mavenCentral();
}

dependencies {

	def joobyVer =  "2.15.1"
	implementation group: "io.jooby", name: "jooby-netty", version: joobyVer;
	implementation group: "io.jooby", name: "jooby-gson", version: joobyVer;
	implementation group: "io.jooby", name: "jooby-swagger-ui", version: joobyVer;
	implementation group: "io.jooby", name: "jooby-pac4j", version: joobyVer;

	implementation group: "com.google.guava", name: "guava", version: "31.1-jre";


	def pac4jVer = "4.5.6";
	implementation group: "org.pac4j", name: "pac4j-http", version: "4.5.6";
	implementation group: "org.pac4j", name: "pac4j-oidc", version: "4.5.6";

	implementation group: "org.slf4j", name: "slf4j-api", version: "1.7.36";
	implementation group: "ch.qos.logback", name: "logback-classic", version: "1.2.11";
}

sourceSets {
	"static" {
		resources {
			srcDirs = ["static"]
		}
		java{
			srcDirs = []
		}
	}
}

/* convenience tasks for working with a project */

tasks.register("createMissingSourceDirs") {
    group = "Project";
    description = "Create all of the missing source directories for this project.";
    doFirst {
        sourceSets.each { def sourceRoot ->
            sourceRoot.allSource.srcDirTrees.each { def sourceDir ->
                if(!sourceDir.dir.exists()) {
                    println "Creating ${sourceDir}";
                    mkdir sourceDir.dir;
                }
            }
        }
    }
}

tasks.register("deleteEmptySourceDirs") {
    group = "Project";
    description = "Delete empty source directories.";
    doFirst {
        sourceSets.each { def sourceRoot ->
            sourceRoot.allSource.srcDirTrees.each { def sourceDir ->
                if(sourceDir.dir.exists() && sourceDir.dir.isDirectory() && sourceDir.dir.list().length == 0) {
                    println "Removing empty ${sourceDir}";
                    sourceDir.dir.delete();
                }
            }
        }
    }
}

tasks.register("openProjectDir") {
    group = "Project";
    description = "Open the project directory in the system file manager.";
    doFirst {
        println("Opening: " + file(projectDir));
        java.awt.Desktop.getDesktop().open(file(projectDir));
    }
}

tasks.register("openBuildDir") {
    group = "Project";
    description = "Open the project build directory in the system file manager.";
    doFirst {
        println("Opening: " + file(buildDir));
        java.awt.Desktop.getDesktop().open(file(buildDir));
    }
}

tasks.register("createGitIgnore") {
    group = "Project";
    description = "Create the project's .gitignore file.";

    def gitIgnored="""
        .gradle/
        .nb-gradle/
        nbproject/
        build/
        bin/
        dist/
        tmp/
        .classpath
        .project
        *.zip
        *.tgz
        *.tar.gz
        *.class
        *.jar
        .DS_Store
        !gradle-wrapper.jar
        """;

    doLast {
        def file = new File(projectDir, ".gitignore");
        if ( !file.exists() ) {
            println("Creating .gitignore");

            gitIgnored.lines().each { f ->
                if(!f.trim().isBlank()) {
                    file.append(f.trim()+"\n");
                }
            }

        } else {
            println(".gitignore already exists");
        }
    }
}