Skip to content
Snippets Groups Projects
Commit 3fe27e18 authored by Peppi-Lotta Saari's avatar Peppi-Lotta Saari
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
Pipeline #38266 passed
contracts/
.classpath
.project
.history/
.idea
.jqwik-database
.lib/
.worksheet
.settings/
*.iml
*.ipr
*.iws
*.log
project/boot/
project/plugins/project/
project/project/
project/*-shim.sbt
project/target/
target/
openjfx/
image: maven:latest
variables:
# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version"
# -DinstallAtEnd=true -DdeployAtEnd=true"
# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add ''
cache:
key: "$CI_JOB_NAME"
paths:
- .m2/repository
build:
stage: build
script:
- mvn compile
test:
stage: test
script:
- mvn test
# Project description
Simple template for projects that make use of JavaFX and FXML (Scene Builder).
Requires Java 11 or later. Compatible with
Eclipse and IntelliJ IDEA. Minor issues with Netbeans. Automatically
integrates with Gitlab CI.
## Installation
Maven:
```bash
$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx
$ cd template-javafx
$ mvn compile exec:java
```
SBT:
```bash
$ git clone https://gitlab.utu.fi/tech/education/gui/template-javafx
$ cd template-javafx
$ sbt compile run
```
## Further instructions
* Java platform: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/jvm-platform
* Maven: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/maven-misc
* SBT: https://gitlab.utu.fi/soft/ftdev/wikis/tutorials/sbt-misc
External sources:
* JavaFX: https://openjfx.io/javadoc/11/
* Scene Builder: https://docs.gluonhq.com/scenebuilder/
// fat jar:
// - gradle jar
// - java -jar build/libs/template-javafx-1.0.jar
// normal jar:
// - gradle jlink
// - java --module-path `find ~/javafx-sdk* -type d -name lib` --add-modules
// javafx.controls,javafx.base,javafx.media,javafx.fxml,javafx.graphics,
// javafx.web,javafx.swing -jar ./build/libs/template-javafx-1.0.jar
//
// or
// - ./build/image/bin/template-javafx
val fatJar = true
group = "fi.utu.tech"
version = "1.0"
plugins {
java
id("org.beryx.jlink") version "2.21.0"
application
}
java {
modularity.inferModulePath.set(true)
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_11
sourceSets["main"].java {
srcDir("src/main/java")
}
sourceSets["main"].resources {
srcDir("src/main/resources")
}
sourceSets["test"].java {
srcDir("src/test/java")
}
sourceSets["test"].resources {
srcDir("src/test/resources")
}
}
repositories {
mavenCentral()
jcenter()
maven("https://ftdev.utu.fi/maven2")
}
dependencies {
implementation("fi.utu.tech", "hotreload", "1.0.0")
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.7.0")
testImplementation("org.junit.jupiter", "junit-jupiter-engine", "5.7.0")
testImplementation("org.junit.jupiter", "junit-jupiter-params", "5.7.0")
testImplementation("org.junit.platform", "junit-platform-commons", "1.7.0")
testImplementation("net.jqwik", "jqwik", "1.3.10")
val jfxOptions = object {
val group = "org.openjfx"
val version = "15.0.1"
val fxModules = arrayListOf(
"javafx-base", "javafx-controls", "javafx-graphics",
"javafx-fxml", "javafx-media", "javafx-web"
)
}
jfxOptions.run {
val osName = System.getProperty("os.name")
val platform = when {
osName.startsWith("Mac", ignoreCase = true) -> "mac"
osName.startsWith("Windows", ignoreCase = true) -> "win"
osName.startsWith("Linux", ignoreCase = true) -> "linux"
else -> "mac"
}
fxModules.forEach {
implementation("$group:$it:$version:$platform")
}
}
}
application{
//mainModule.set("fi.utu.tech.gui.javafx")
mainClass.set("fi.utu.tech.gui.javafx.Main")
applicationDefaultJvmArgs = arrayListOf("-ea")
}
tasks {
getByName<ProcessResources>("processResources") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE // allow duplicates
}
getByName<Jar>("jar") {
doFirst {
manifest {
attributes["Main-Class"] = application.mainClassName
}
if (fatJar) {
from(configurations.getByName("runtimeClasspath").map {
if (it.isDirectory) it else zipTree(it)
})
}
}
}
compileJava {
options.encoding = "UTF-8"
}
}
jlink {
jpackage {
jvmArgs = listOf("-ea")
outputDir = "apps"
imageName = "template-javafx"
}
}
// javafxplugin is currently broken
// https://github.com/openjfx/javafx-gradle-plugin/issues/89
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.9'
}
modularity.disableEffectiveArgumentsAdjustment()
mainClassName = 'fi.utu.tech.gui.javafx.Main'
sourceCompatibility = 11
javafx {
version = "15.0.1"
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics', 'javafx.media', 'javafx.web' ]
}
jar {
manifest {
attributes 'Main-Class': mainClassName
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
// maven directory layout
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
resources {
srcDirs = ['src/main/resources']
}
}
test {
java {
srcDirs = ['src/test/java']
}
resources {
srcDirs = ['src/test/resources']
}
}
}
// hot reload plugin
repositories {
jcenter()
repositories {
maven {
url "https://ftdev.utu.fi/maven2"
}
}
}
// junit, jqwik, hot reload plugin
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.0'
testImplementation 'org.junit.platform:junit-platform-commons:1.7.0'
testImplementation 'net.jqwik:jqwik:1.3.10'
implementation 'fi.utu.tech:hotreload:1.0.0'
}
build.sbt 0 → 100644
// Project template
// Supported operating systems: Windows, Mac, Linux
// Supported JDKs: 8, 10+
// Project name
name := "template-javafx"
// organization name
organization := "fi.utu.tech"
version := "1.0"
// project description
description := "JavaFX project template"
// main class
Compile/mainClass := Some("fi.utu.tech.gui.javafx.Main")
// force the java version by typing it here (remove the comment)
val force_javaVersion = None // Some(15)
// force the javafx version by typing it here (remove the comment)
val force_javaFxVersion = None // Some(15)
val useJavaFX = true
val useScalaOrScalaFX = true
// END_OF_SIMPLE_CONFIGURATION
// you can copy the rest for each new project
// --- --- ---
def fail(msg: String) = {
println("Error :-/")
println
println(msg)
System.exit(1)
null
}
val detectedJDK = System.getProperty("java.version").replace("-ea","").split('.').dropWhile(_.toInt<8).head.toInt
val javaVersionNum = force_javaVersion.getOrElse(detectedJDK)
val javaVersionString = javaVersionNum match {
case 7 => "1.7"
case 8 => "1.8"
case x if x > 8 => x.toString
}
val lts = 11
val dev = 15
val supported = javaVersionNum match {
case x if x < 8 => fail("Your Java installation is obsolete. Please upgrade to Java " + lts + "LTS")
case 9 => fail("Your Java installation is unsupported and has known issues. Please upgrade to Java " + lts + "LTS")
case x if x < lts => println("Consider upgrading to Java " + lts + " LTS"); true
case x if x > lts && x < dev => println("Consider upgrading to Java " + dev); true
case x if x > dev => println("Unsupported early access version. Consider switching back to Java " + dev); true
case _ => true
}
javacOptions ++= Seq("-source", javaVersionString, "-target", javaVersionString, "-encoding", "utf8", "-Xlint:unchecked", "-Xlint:deprecation")
javacOptions in doc := Seq("-source", javaVersionString)
enablePlugins(JShellPlugin)
compileOrder := CompileOrder.JavaThenScala
// Enables publishing to maven repo
publishMavenStyle := true
// Do not append Scala versions to the generated artifacts
crossPaths := false
// This forbids including Scala related libraries into the dependency
autoScalaLibrary := false
assemblyMergeStrategy in assembly := {
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case _ => MergeStrategy.first
}
// contains libraries provided by utu/ft dep
resolvers += "ftdev" at "https://ftdev.utu.fi/maven2"
fork in Global := true
val javaVersion = taskKey[Unit]("Prints the Java version.")
javaVersion := { println("SBT uses Java SDK located at "+System.getProperty("java.home")) }
publishTo := Some(Resolver.file("file", new File("/tmp/repository")))
val oomkit = "fi.utu.tech" % "oomkit" % "1.22"
libraryDependencies ++= Seq()
////
//// JQWIK / JUNIT configuration
////
resolvers in ThisBuild += Resolver.jcenterRepo
val junit_version = "5.7.0"
// library dependencies. (orginization name) % (project name) % (version)
libraryDependencies ++= Seq(
"net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test,
"org.junit.platform" % "junit-platform-commons" % ("1"+junit_version.tail) % Test,
"org.junit.platform" % "junit-platform-runner" % ("1"+junit_version.tail) % Test,
"org.junit.jupiter" % "junit-jupiter-engine" % junit_version % Test,
"org.junit.jupiter" % "junit-jupiter-api" % junit_version % Test,
"org.junit.jupiter" % "junit-jupiter-migrationsupport" % junit_version % Test,
"org.junit.jupiter" % "junit-jupiter-params" % junit_version % Test,
"net.jqwik" % "jqwik" % "1.3.10" % Test,
"org.scalatest" %% "scalatest" % "3.0.8" % Test,
)
testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-c")
////
//// JAVAFX configuration
////
val javafx_versions = if (!useJavaFX) (0,"-","-") else (force_javaFxVersion getOrElse javaVersionNum) match {
case 7 => (7, "7", "8.0.181-R13")
case 8 => (8, "8", "8.0.181-R13")
// case 10 => (11, "11.0.2", "11-R16")
case x if x>10 => (15, "15.0.1", "15.0.1-R21")
case _ => fail("Unsupported Java version for JavaFX")
}
// JAVA_HOME location
val javaHomeDir = {
val path = try {
if (scala.sys.env("JAVA_HOME").trim.isEmpty) throw new Exception("Empty JAVA_HOME") else scala.sys.env("JAVA_HOME")
} catch {
case _: Throwable => System.getProperty("java.home") // not set -> ask from current JVM
}
val f = file(path)
if (!f.exists()) fail("The environment variable JAVA_HOME points to a non-existent directory!\nSolution: Edit your system settings (Windows control panel / *nix .bashrc) and fix the JAVA_HOME location.")
f
}
val osName: SettingKey[String] = SettingKey[String]("osName")
osName := (System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
})
def legacyJavaFX() = {
val searchDirs = Seq(
"/jre/lib/jfxrt.jar", // OpenJDK 7
"/jre/lib/ext/jfxrt.jar", // OpenJDK 8
"/lib/ext/jfxrt.jar" // Windows & Oracle Java 8
)
if (detectedJDK > 8) fail(s"Trying to use legacy non-modular JavaFX with a modern JDK [$detectedJDK].\nSolution: Check the line 'val force_javaFxVersion =' in build.sbt.")
val javaFxJAR = searchDirs.map{ searchDir => file(javaHomeDir + searchDir) }.find{ _.exists() }
javaFxJAR.getOrElse {
fail(s"Java FX runtime not installed in [${javaHomeDir.toString}]!\nSolution: Install JavaFX or consider upgrading your JDK so that JavaFX can be installed automatically.")
}
}
val jfx_sdk_version = javafx_versions._2
val jfx_scalafx_version = javafx_versions._3
val javaFxPath = Def.taskKey[File]("OpenJFX fetcher")
javaFxPath := {
val javaFxHome =
try {
val envHome = file(scala.sys.env("JAVAFX_HOME"))
if (envHome.toString.trim.isEmpty) throw new Exception("Empty JAVAFX_HOME")
println("Using OpenJFX from " + envHome)
envHome
}
catch { case _: Throwable =>
println("Using local OpenJFX")
baseDirectory.value / "openjfx"
}
if (!javaFxHome.exists()) java.nio.file.Files.createDirectory(javaFxHome.toPath)
val jfx_os = osName.value match {
case "linux" => "linux"
case "mac" => "osx"
case "win" => "windows"
}
val sdkURL = "http://download2.gluonhq.com/openjfx/" + jfx_sdk_version + "/openjfx-" + jfx_sdk_version + "_" + jfx_os + "-x64_bin-sdk.zip"
try {
val testDir = javaFxHome / "all.ok"
if (!testDir.exists()) {
println("Fetching OpenJFX from "+sdkURL+"..")
IO.unzipURL(new URL(sdkURL), javaFxHome)
java.nio.file.Files.createDirectory(testDir.toPath)
println("Fetching OpenJFX done.")
} else {
println("Using OpenJFX from "+javaFxHome)
}
javaFxHome
}
catch {
case t: Throwable => fail("Could not load OpenJFX! Reason:" + t.getMessage)
}
}
val jfxModules = Seq("base","controls","fxml","graphics","media","swing","web")
if (!useJavaFX) Seq() else javafx_versions._1 match {
case 7 =>
// TODO libraryDependencies
Seq(unmanagedJars in Compile += Attributed.blank(legacyJavaFX()))
case 8 =>
(if (useScalaOrScalaFX) Seq(libraryDependencies += "org.scalafx" %% "scalafx" % jfx_scalafx_version) else Seq()) ++
Seq(unmanagedJars in Compile += Attributed.blank(legacyJavaFX()))
case _ =>
Seq(
javaOptions in run ++= Seq(
"--module-path", (javaFxPath.value / ("javafx-sdk-" + jfx_sdk_version) / "lib").toString,
"--add-modules=" + jfxModules.map("javafx."+_).mkString(","))
) ++
(if (useScalaOrScalaFX) Seq(libraryDependencies += "org.scalafx" % "scalafx_2.13" % jfx_scalafx_version) else Seq()) ++
jfxModules.map(module => libraryDependencies += "org.openjfx" % ("javafx-"+module) % jfx_sdk_version classifier osName.value)
}
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- See https://tech.utugit.fi/soft/tools/lectures/tko8971/build/ -->
<!-- ==== START OF SIMPLE CONFIGURATION ==== -->
<!-- The three parts of the artifact name -->
<groupId>fi.utu.tech</groupId>
<artifactId>template-javafx</artifactId>
<version>1.0</version>
<!-- Additional information about the project -->
<name>JavaFX project template</name>
<url>https://gitlab.utu.fi/tech/education/gui/template-javafx</url>
<!-- We want to generate a jar. Don't change. -->
<packaging>jar</packaging>
<properties>
<!-- Configures the main class for this project (i.e. what to launch) -->
<project.mainclass>fi.utu.tech.gui.javafx.Main</project.mainclass>
<!-- The source encoding should always be utf-8. Don't change. -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Version numbers for various modules -->
<jdk.version>11</jdk.version>
<jqwik.version>1.3.10</jqwik.version>
<junit.version>5.7.0</junit.version>
<junitplatform.version>1.7.0</junitplatform.version>
<javafx.version>15.0.1</javafx.version>
</properties>
<!-- ==== END OF SIMPLE CONFIGURATION ==== -->
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>jcenter</id>
<name>jcenter</name>
<url>https://jcenter.bintray.com/</url>
</repository>
<!-- UTU repository -->
<repository>
<id>ftdev</id>
<name>ftdev</name>
<url>https://ftdev.utu.fi/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>${junitplatform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.jqwik</groupId>
<artifactId>jqwik</artifactId>
<version>${jqwik.version}</version>
<scope>test</scope>
</dependency><!--
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junitplatform.version}</version>
<scope>test</scope>
</dependency> -->
<!-- JavaFX (remove if not needed to speed up dep downloads)-->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Make a 'fat' jar, that is, jar that contains all its dependencies and runs as is.
See: https://stackoverflow.com/a/57691362 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${project.mainclass}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run this app with exec:java -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>${project.mainclass}</mainClass>
<arguments>
<argument>arg1</argument>
<argument>arg2</argument>
</arguments>
</configuration>
</plugin>
<!-- Make the packaged jar executable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<!-- DO NOT include log4j.properties file in your Jar -->
<excludes>
<exclude>**/log4j.properties</exclude>
</excludes>
<archive>
<manifest>
<!-- Jar file entry point -->
<mainClass>${project.mainclass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- JDK source/target versions -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Also create a jar of the sources -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- JShell (jshell:run) -->
<plugin>
<groupId>com.github.johnpoth</groupId>
<artifactId>jshell-maven-plugin</artifactId>
<version>1.3</version>
</plugin>
<!-- UTU DbC Javadoc annotations -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<tags>
<tag>
<name>toDo</name>
<placement>a</placement>
<head>To&nbsp;do:</head>
</tag>
<tag>
<name>classInvariant</name>
<placement>t</placement>
<head>Class&nbsp;invariant:</head>
</tag>
<tag>
<name>classInvariantProtected</name>
<placement>t</placement>
<head>Protected&nbsp;class&nbsp;invariant:</head>
</tag>
<tag>
<name>classInvariantPrivate</name>
<placement>t</placement>
<head>Private&nbsp;class&nbsp;invariant:</head>
</tag>
<tag>
<name>abstractionFunction</name>
<placement>t</placement>
<head>Abstraction&nbsp;function:</head>
</tag>
<tag>
<name>pre</name>
<placement>cm</placement>
<head>Precondition:</head>
</tag>
<tag>
<name>post</name>
<placement>cm</placement>
<head>Postcondition:</head>
</tag>
<tag>
<name>postProtected</name>
<placement>cm</placement>
<head>Protected&nbsp;postcondition:</head>
</tag>
<tag>
<name>postPrivate</name>
<placement>cm</placement>
<head>Private&nbsp;postcondition:</head>
</tag>
<tag>
<name>time</name>
<placement>cmf</placement>
<head>Time&nbsp;complexity:</head>
</tag>
<tag>
<name>space</name>
<placement>cmf</placement>
<head>Space&nbsp;complexity:</head>
</tag>
<tag>
<name>correspondence</name>
<placement>a</placement>
<head>Correspondence:</head>
</tag>
<tag>
<name>download</name>
<placement>a</placement>
<head>Download:</head>
</tag>
</tags>
<show>protected</show>
<failOnError>false</failOnError>
<sourceFileExcludes>
<sourceFileExclude>**/module-info.java</sourceFileExclude>
</sourceFileExcludes>
</configuration>
</plugin>
<!-- JUnit & JQwik test integration -->
<!-- junit-platform-maven-plugin: supports modular tests
maven-surefire-plugin: non-modular tests
Modular testing works via command line mvn, but is
still broken in Eclipse due to this
https://bugs.eclipse.org/bugs/show_bug.cgi?id=520667
<plugin>
<groupId>de.sormuras.junit</groupId>
<artifactId>junit-platform-maven-plugin</artifactId>
<version>1.0.0-M5</version>
<extensions>true</extensions>
<configuration>
<executor>JAVA</executor>
</configuration>
</plugin>-->
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<!-- javafx:jlink:
https://github.com/openjfx/javafx-maven-plugin
Use 'mvn package' instead if you don't need jlink.
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>${project.mainclass}</mainClass>
</configuration>
</plugin> -->
</plugins>
<extensions>
<!-- Enables the use of SSH for deployments -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>3.4.2</version>
</extension>
</extensions>
</build>
<distributionManagement>
<repository>
<id>ftdev</id>
<name>UTU tech ftdev repository</name>
<url>scp://localhost:2222/var/www/maven2</url>
</repository>
</distributionManagement>
</project>
sbt.version=1.4.6
resolvers += Resolver.jcenterRepo
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")
addSbtPlugin("net.aichler" % "sbt-jupiter-interface" % "0.8.3")
addSbtPlugin("com.github.xuwei-k" % "sbt-jshell" % "0.1.2")
//addSbtPlugin("org.xerial.sbt" % "sbt-sql-sqlite" % "0.8")
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")
package fi.utu.tech.gui.javafx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
// Getting the reference to "class object of this class"
var resourceRoot = getClass();
// The fxml filename that is in resources folder
var form = "posankkamenu.fxml";
// Give the FXML resource to the FXMLLoader
var loader = new FXMLLoader(resourceRoot.getResource(form));
// Load and parse the FXML into an Java object (Parent)
Parent root = loader.load();
// This is just the usual: Setting scene, showing stage
stage.setTitle("Posankanupotus");
var scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
// declarate module imports and exports here
// see: https://tech.utugit.fi/soft/tools/lectures/tko8971/build/jpms/
module fi.utu.tech.gui.javafx {
//requires java.desktop;
requires transitive javafx.base;
requires transitive javafx.fxml;
requires transitive javafx.controls;
requires transitive javafx.graphics;
requires transitive javafx.media;
requires transitive javafx.web;
exports fi.utu.tech.gui.javafx;
opens fi.utu.tech.gui.javafx;
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Spinner?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Font?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="474.0" prefWidth="727.0" style="-fx-background-color: PINK;" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1">
<center>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" BorderPane.alignment="CENTER">
<children>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Pelaaja 1" />
<TextField promptText="Anna nimi" />
</children>
</VBox>
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Pelaaja 2" />
<TextField promptText="Anna nimi" />
</children>
</VBox>
</children>
</HBox>
<VBox alignment="TOP_CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" text="Ruudukon koko" />
<ChoiceBox prefHeight="26.0" prefWidth="164.0" />
<VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0">
<children>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Label text="Lentotukiposankka 5" />
<Spinner prefHeight="26.0" prefWidth="55.0" style="-fx-background-color: BLACK;" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Label text="Taistelijaposankka 4" />
<Spinner prefHeight="26.0" prefWidth="55.0" style="-fx-background-color: FF694B;" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Label prefHeight="16.0" prefWidth="133.0" text="Risteilyposankka 3" />
<Spinner prefHeight="26.0" prefWidth="56.0" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Label text="Sukellusposankka 3" />
<Spinner prefHeight="26.0" prefWidth="59.0" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<children>
<Label text="Kevytposankka 2" />
<Spinner prefHeight="26.0" prefWidth="54.0" />
</children>
</HBox>
</children>
</VBox>
</children>
</VBox>
</children>
</VBox>
</center>
<bottom>
<Button alignment="BOTTOM_RIGHT" mnemonicParsing="false" prefHeight="49.0" prefWidth="103.0" style="-fx-background-color: #FF69B4;" text="Aloita" textFill="ROYALBLUE" BorderPane.alignment="BOTTOM_RIGHT">
<BorderPane.margin>
<Insets bottom="25.0" right="60.0" />
</BorderPane.margin>
<padding>
<Insets bottom="9.0" right="17.0" />
</padding>
<font>
<Font name="Quicksand Bold" size="25.0" />
</font>
</Button>
</bottom>
<top>
<Label text="Posankanupotus" textFill="ROYALBLUE" BorderPane.alignment="CENTER">
<font>
<Font name="Quicksand Bold" size="60.0" />
</font>
</Label>
</top>
</BorderPane>
package fi.utu.tech.gui.javafx;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class DummyTest {
@Test
public void dummy() throws Exception {
assertTrue(true);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment