Skip to content

Commit

Permalink
mvnw and travis
Browse files Browse the repository at this point in the history
  • Loading branch information
danlangford committed Dec 29, 2018
1 parent 32275a9 commit c4209c6
Show file tree
Hide file tree
Showing 11 changed files with 625 additions and 17 deletions.
110 changes: 110 additions & 0 deletions .mvn/wrapper/MavenWrapperDownloader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/

import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;

public class MavenWrapperDownloader {

/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";

/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";

/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";

/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";

public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());

// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);

File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}

private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}

}
1 change: 1 addition & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: java
jdk: openjdk11
deploy:
provider: releases
api_key:
secure: T0BP+4oS9yBJ/z17DW9EZmdy5D1UoSIK5GSeEZtf2esTHVO+4hmG0mdObg8JiwJs+TGRecDM0Crbm4JFjKdndf9F4CNY0Y4pUF2zbWxMAwc2wCy+Ra80jJYnzSwHLhaLf/pyS4KuzOwqQF7eUbHBQhvJCotb6TBqUd8sTQaRb1Ut8976LH33hQNiK0WY/Pd3q7sAbmGoXVrHjZrnm/A1pJPUJvNm7TFG4cVF/wizVr/Ws2C2LjP5cvxRHJJPUtOYe00C3HLK6prY1rgjmGEgJC/sEWSSNtmbY/OpRW/oaCU6bFCalp5VFW9je6bfvY3sKkn25+tjDwJyjT19QeNZtdDXFGSUnF2EkK14uzfMAdcKv9eCSd90IgmIhfIQIuniutxzzlM+BOfB+nsnahO+750fxfD51LJAOUx6WPU6Yc+65jUPBZhv0QQH8lzs6YvBkh0yrtYyMwb5nWaHIJ6Me7zbsLIp5sV0Spy+ubkPjRbGdXD9rsqW5hkZFYIF9P5+fuySX6M23PozsvReeYvgrrZ4cyOIxeQrdYhnw1xVEwxqb5QDjrTJBjsulKLi27FJGGwCCHFVEDjvLfz4GpityLKVWBR1xlag1/nu51QAMtFECHEIPxlqmyBNZZsdCl3umrGremuvlukuM+X7Fq1tDmx80vF5j7Rxxn8JSEHl01E=
file:
- target/tableflipper-cli-0.0.5.jar
- target/tableflipper-ui-0.0.5.jar
on:
tags: true
24 changes: 15 additions & 9 deletions README.asc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
= Table Flipper 0.0.4
= Table Flipper v0.0.5
:toc:
:sectlinks:
:sectanchors:
Expand All @@ -14,7 +14,9 @@ CAUTION: this README.asc was auto created from original src/main/doc

== Info

a way for Dungeon Masters to collect, build, and roll on their collection of favorite tables.
image:https://travis-ci.org/danlangford/tableflipper.svg?branch=master["Build Status", link="https://travis-ci.org/danlangford/tableflipper"]

A way for Dungeon Masters to collect, build, and roll on their collection of favorite tables.
the recursive template feature allows table results to mention dice rolls or other table results that all get resolved into one nice easy to read message.
currently it loads up tables from the 5e SRD.

Expand All @@ -37,20 +39,20 @@ interesting Entry points (Main methods) to run:

== Requirements

you will need Java 11+ to run this and Maven 3.6+ to build this
you will need Java 11+ to run this. Maven 3.6+ is required to build this and that should be taken care of by the included maven wrapper `./mvnw`

TIP: you can obtain Java 11 from https://adoptopenjdk.net/[AdoptOpenJDK], https://sdkman.io/[sdkman], or https://brew.sh/[Homebrew].

== Getting Started

run

mvn package
./mvnw package

look for output

[INFO] ----------------------------------------------------
[INFO] Reactor Summary for tableflipper 0.0.4:
[INFO] Reactor Summary for tableflipper 0.0.5:
[INFO]
[INFO] tableflipper ................... SUCCESS [ 1.992 s]
[INFO] tableflipper-core .............. SUCCESS [ 2.285 s]
Expand All @@ -64,16 +66,20 @@ look for output

now you can run

java -jar target/tableflipper-cli-0.0.4.jar
java -jar target/tableflipper-cli-0.0.5.jar

or

java -jar target/tableflipper-ui-0.0.4.jar
java -jar target/tableflipper-ui-0.0.5.jar

and copy those JARs to wherever you need them.

and at least in MacOS I can just double click the `tableflipper-ui-0.0.4.jar` to have it executed.
and at least in MacOS I can just double click the `tableflipper-ui-0.0.5.jar` to have it executed.

== Advanced

you can run the build with the `multiplatform` profile to have the ui fatjar include all the javafx graphics for all three platforms adding a couple MB to the size. i still need to test that it actually works.
you can run the build with the `multiplatform` profile to have the ui fatjar include all the javafx graphics for all three platforms adding a few MB to the size. i still need to test that it actually works.

./mvnw package -Pmultiplatform

_Dan "8bagels" Langford_
2 changes: 2 additions & 0 deletions done.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x 2018-12-28 add more information on Readme about building and running the applications
x 2018-12-28 mvnw config to force travis on correct maven version
Loading

0 comments on commit c4209c6

Please sign in to comment.