Changes the build structure to put the library in its own project.

This cleans up dependencies some.
This commit is contained in:
Markil3
2020-12-14 11:56:48 -07:00
parent b7bfb13745
commit a052c47573
7 changed files with 203 additions and 85 deletions

1
.gitignore vendored
View File

@@ -23,5 +23,6 @@
hs_err_pid*
/local.properties
/build/
/library/build/
/.idea/
/.gradle/

View File

@@ -24,9 +24,9 @@ Alternatively, you can [download the zip file](https://github.com/Markil3/JMECon
Once downloaded, point the command line to the directory that the source was downloaded and extracted to and run
<code>gradlew build</code>
<code>gradlew library:build</code>
This will create three .jar files in the build/libs directory, one binary, the second (with the -source suffix) containing the source code, and the final one (with the -javadoc suffix) containing documentation.
This will create three .jar files in the library/build/libs directory, one binary, the second (with the -source suffix) containing the source code, and the final one (with the -javadoc suffix) containing documentation.
## Testing
If you want to test this without implementing it in your software, simply download the source as outlined above and run

View File

@@ -17,15 +17,14 @@ buildscript {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
plugins {
id "java-library"
id "application"
id "distribution"
id "com.github.johnrengelman.shadow" version "5.0.0"
id "edu.sc.seis.launch4j" version "2.4.5"
id "edu.sc.seis.macAppBundle" version "2.3.0"
}
repositories {
@@ -52,10 +51,9 @@ dependencies {
implementation "org.slf4j:slf4j-api:1.7.15"
implementation "org.slf4j:slf4j-simple:1.7.5"
implementation project(':library')
implementation "${jme3.g}:jme3-core:${jme3.version}"
implementation "${jme3.g}:jme3-desktop:${jme3.version}"
implementation "${jme3.g}:jme3-testdata:${jme3.version}"
implementation "${jme3.g}:jme3-lwjgl3:${jme3.version}"
}
@@ -64,19 +62,61 @@ mainClassName = 'markil3.controller.Main'
version = "1.0"
versionNumber = 1
java {
withSourcesJar()
withJavadocJar()
processResources {
from (".") {
include "LICENSE"
include "JME3-LICENSE"
}
}
/*
* TODO - The default zipped distributions are a bit of a mess.
*/
jar {
baseName rootProject.name
version rootProject.version
manifest {
attributes "Main-Class": mainClassName,
"Class-Path": configurations.runtime.files.collect {
"lib/$it.name"
}.join(" "),
"Implementation-Title": rootProject.displayName,
"Implementation-Title": rootProject.name,
"Implementation-Version": rootProject.version,
"Version-Code": versionNumber
}
}
shadowJar {
archivesBaseName = rootProject.name
archiveClassifier = "universal"
version = rootProject.version
mainClassName = project.mainClassName
}
launch4j {
mainClassName = project.mainClassName
outfile = rootProject.name + "-" + project.version + "-windows.exe"
copyConfigurable = shadowJar.outputs.files
jar = shadowJar.getArchiveFile()
bundledJrePath = "jre"
//icon = new File(sourceSets.main.resources.srcDirs[0], "icon256.ico")
}
createExe.doLast({
println project.tasks.installDist.outputs.files.getClass()
for (file in new File(installDist.outputs.files[0], "lib").listFiles()) {
println file
}
})
macAppBundle {
mainClassName = project.mainClassName
icon = "myIcon.icns"
if (Os.isFamily(Os.FAMILY_MAC) && (appStyle == 'Oracle' || appStyle == 'universalJavaApplicationStub')) {
bundleJRE = true
}
javaProperties.put("apple.laf.useScreenMenuBar", "true")
backgroundImage = "doc/macbackground.png"
jarTask = "shadowJar"
}

93
library/build.gradle Normal file
View File

@@ -0,0 +1,93 @@
/*
* Copyright 2020 Markil 3. All rights reserved.
*
* 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 org.apache.tools.ant.taskdefs.condition.Os
import java.nio.file.Files
buildscript {
repositories {
jcenter()
google()
}
}
plugins {
id "java-library"
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url "https://dl.bintray.com/jmonkeyengine/org.jmonkeyengine"
}
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
dependencies {
// Logging
implementation "org.slf4j:slf4j-api:1.7.15"
implementation "org.slf4j:slf4j-simple:1.7.5"
implementation "${jme3.g}:jme3-core:${jme3.version}"
implementation "${jme3.g}:jme3-testdata:${jme3.version}"
}
processResources {
from ("..") {
include "LICENSE"
include "JME3-LICENSE"
}
}
/*
* TODO - Why does the shadowjar task in the main project run when we use library:build?
*/
java {
withSourcesJar()
withJavadocJar()
}
sourcesJar {
baseName rootProject.name
version rootProject.version
from ("..") {
include "LICENSE"
include "JME3-LICENSE"
}
}
javadocJar {
baseName rootProject.name
version rootProject.version
from ("..") {
include "LICENSE"
include "JME3-LICENSE"
}
}
jar {
baseName rootProject.name
version rootProject.version
manifest {
attributes "Class-Path": configurations.runtime.files.collect {
"lib/$it.name"
}.join(" "),
"Implementation-Title": rootProject.name,
"Implementation-Version": rootProject.version,
"Version-Code": rootProject.versionNumber
}
}

View File

@@ -45,23 +45,6 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import static markil3.controller.Main.ACTION_BOTTOM;
import static markil3.controller.Main.ACTION_LEFT;
import static markil3.controller.Main.ACTION_RIGHT;
import static markil3.controller.Main.ACTION_TOP;
import static markil3.controller.Main.DPAD_DOWN;
import static markil3.controller.Main.DPAD_LEFT;
import static markil3.controller.Main.DPAD_RIGHT;
import static markil3.controller.Main.DPAD_UP;
import static markil3.controller.Main.L1;
import static markil3.controller.Main.L2;
import static markil3.controller.Main.L3;
import static markil3.controller.Main.R1;
import static markil3.controller.Main.R2;
import static markil3.controller.Main.R3;
import static markil3.controller.Main.SELECT;
import static markil3.controller.Main.START;
/**
* Adding this app state will display a GUI screen showing the controllers
* connected and information on what buttons are pressed. It is primarily
@@ -85,6 +68,61 @@ public class JoystickPreviewScreen extends BaseAppState
private static final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(JoystickPreviewScreen.class);
/**
* Triangle on Playstation, Y on Xbox, and X on Nintendo.
*/
public static final String ACTION_TOP = JoystickButton.BUTTON_0;
/**
* Circle on Playstation, B on Xbox, and A on Nintendo.
*/
public static final String ACTION_RIGHT = JoystickButton.BUTTON_1;
/**
* X on Playstation, A on Xbox, and B on Nintendo.
*/
public static final String ACTION_BOTTOM = JoystickButton.BUTTON_2;
/**
* Square on Playstation, X on Xbox, and Y on Nintendo.
*/
public static final String ACTION_LEFT = JoystickButton.BUTTON_3;
public static final String L1 = JoystickButton.BUTTON_4;
public static final String R1 = JoystickButton.BUTTON_5;
/**
* Some gamepads (Xbox controllers notable) will use
* {@link JoystickAxis#LEFT_TRIGGER} instead.
*/
public static final String L2 = JoystickButton.BUTTON_6;
/**
* Some gamepads (Xbox controllers notable) will use
* {@link JoystickAxis#RIGHT_TRIGGER} instead.
*/
public static final String R2 = JoystickButton.BUTTON_7;
public static final String SELECT = JoystickButton.BUTTON_8;
public static final String START = JoystickButton.BUTTON_9;
/**
* Pressing the left analog stick.
*/
public static final String L3 = JoystickButton.BUTTON_10;
/**
* Pressing the right analog stick.
*/
public static final String R3 = JoystickButton.BUTTON_11;
/**
* Most gamepads may use {@link JoystickAxis#POV_X} instead.
*/
public static final String DPAD_LEFT = "12";
/**
* Most gamepads may use {@link JoystickAxis#POV_X} instead.
*/
public static final String DPAD_RIGHT = "13";
/**
* Most gamepads may use {@link JoystickAxis#POV_Y} instead.
*/
public static final String DPAD_UP = "14";
/**
* Most gamepads may use {@link JoystickAxis#POV_Y} instead.
*/
public static final String DPAD_DOWN = "15";
/**
* This node serves as the center of logic for each gamepad connected to
* the computer.

View File

@@ -16,3 +16,4 @@ include 'services:webservice'
*/
rootProject.name = 'JMEControllerConfig'
include "library"

View File

@@ -28,61 +28,6 @@ public class Main extends SimpleApplication
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.
getLogger(Main.class);
/**
* Triangle on Playstation, Y on Xbox, and X on Nintendo.
*/
public static final String ACTION_TOP = JoystickButton.BUTTON_0;
/**
* Circle on Playstation, B on Xbox, and A on Nintendo.
*/
public static final String ACTION_RIGHT = JoystickButton.BUTTON_1;
/**
* X on Playstation, A on Xbox, and B on Nintendo.
*/
public static final String ACTION_BOTTOM = JoystickButton.BUTTON_2;
/**
* Square on Playstation, X on Xbox, and Y on Nintendo.
*/
public static final String ACTION_LEFT = JoystickButton.BUTTON_3;
public static final String L1 = JoystickButton.BUTTON_4;
public static final String R1 = JoystickButton.BUTTON_5;
/**
* Some gamepads (Xbox controllers notable) will use
* {@link JoystickAxis#LEFT_TRIGGER} instead.
*/
public static final String L2 = JoystickButton.BUTTON_6;
/**
* Some gamepads (Xbox controllers notable) will use
* {@link JoystickAxis#RIGHT_TRIGGER} instead.
*/
public static final String R2 = JoystickButton.BUTTON_7;
public static final String SELECT = JoystickButton.BUTTON_8;
public static final String START = JoystickButton.BUTTON_9;
/**
* Pressing the left analog stick.
*/
public static final String L3 = JoystickButton.BUTTON_10;
/**
* Pressing the right analog stick.
*/
public static final String R3 = JoystickButton.BUTTON_11;
/**
* Most gamepads may use {@link JoystickAxis#POV_X} instead.
*/
public static final String DPAD_LEFT = "12";
/**
* Most gamepads may use {@link JoystickAxis#POV_X} instead.
*/
public static final String DPAD_RIGHT = "13";
/**
* Most gamepads may use {@link JoystickAxis#POV_Y} instead.
*/
public static final String DPAD_UP = "14";
/**
* Most gamepads may use {@link JoystickAxis#POV_Y} instead.
*/
public static final String DPAD_DOWN = "15";
public static void main(String[] args)
{
Main app = new Main();