-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f191557
commit c469af4
Showing
11 changed files
with
136 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ build/ | |
.settings/ | ||
bin/ | ||
*.launch | ||
!src/test/resources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
import net.neoforged.gradleutils.PomUtilsExtension.License | ||
|
||
plugins { | ||
id 'java-library' | ||
id 'net.neoforged.gradleutils' | ||
id 'net.neoforged.gradleutils' version '3.+' | ||
id 'maven-publish' | ||
id 'signing' | ||
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0' | ||
} | ||
|
||
group = 'net.neoforged' | ||
version = gradleutils.getTagOffsetVersion() | ||
version = gradleutils.version | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
gradleutils { | ||
setupSigning() | ||
setupCentralPublishing() | ||
} | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
|
@@ -22,9 +27,13 @@ java { | |
} | ||
|
||
dependencies { | ||
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:0.4.2' | ||
compileOnly 'com.github.bsideup.jabel:jabel-javac-plugin:0.4.2' | ||
annotationProcessor 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' | ||
annotationProcessor("net.java.dev.jna:jna-platform:5.13.0") | ||
compileOnly 'com.github.bsideup.jabel:jabel-javac-plugin:1.0.0' | ||
compileOnly 'org.jetbrains:annotations:24.0.1' | ||
|
||
testImplementation(libs.junit.api) | ||
testRuntimeOnly(libs.junit.engine) | ||
} | ||
|
||
// Uses https://github.com/bsideup/jabel to compile to Java 8 from Java 16 source. | ||
|
@@ -50,25 +59,11 @@ tasks.withType(Javadoc).configureEach { | |
options.addStringOption('Xdoclint:all,-missing', '-public') | ||
} | ||
|
||
tasks.register('hello') { | ||
doLast { | ||
println 'Hello from Gradle!' | ||
if (project.hasProperty('helloReply')){ | ||
println helloReply | ||
} | ||
// Test for --no-daemon launches to verify that the task was invoked. | ||
new File(projectDir, "hello.txt").text = "Hello from Gradle inside a file!" | ||
} | ||
} | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
username.set(System.getenv('SONATYPE_USER') ?: '') | ||
password.set(System.getenv('SONATYPE_PASSWORD') ?: '') | ||
nexusUrl.set(uri('https://s01.oss.sonatype.org/service/local/')) | ||
} | ||
} | ||
test { | ||
javaLauncher.set(javaToolchains.launcherFor { | ||
languageVersion = JavaLanguageVersion.of(17) | ||
}) | ||
useJUnitPlatform() | ||
} | ||
|
||
publishing { | ||
|
@@ -79,52 +74,18 @@ publishing { | |
pom { | ||
name = project.name | ||
description = 'A Java library for generating Eclipse Launch Configurations (.launch files).' | ||
url = 'https://github.com/NeoForged/EclipseLaunchConfigs' | ||
|
||
scm { | ||
url = 'https://github.com/NeoForged/EclipseLaunchConfigs' | ||
connection = 'scm:git:git://github.com/NeoForged/EclipseLaunchConfigs.git' | ||
developerConnection = 'scm:git:[email protected]:NeoForged/EclipseLaunchConfigs.git' | ||
} | ||
|
||
issueManagement { | ||
system = 'github' | ||
url = 'https://github.com/NeoForged/EclipseLaunchConfigs/issues' | ||
} | ||
|
||
licenses { | ||
license { | ||
name = 'LGPL 2.1' | ||
url = 'https://github.com/NeoForged/EclipseLaunchConfigs/blob/main/LICENSE' | ||
distribution = 'repo' | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id = 'neoforged' | ||
name = 'NeoForged' | ||
email = '[email protected]' | ||
url = 'https://github.com/NeoForged/' | ||
} | ||
} | ||
|
||
pomUtils.neoForgedDeveloper(it) | ||
pomUtils.license(it, License.LGPL_v2) | ||
pomUtils.githubRepo(it, 'EclipseLaunchConfigs') | ||
} | ||
} | ||
} | ||
repositories { | ||
maven gradleutils.getPublishingForgeMaven() | ||
maven gradleutils.publishingMaven | ||
} | ||
} | ||
|
||
changelog { | ||
fromTag '0.1' | ||
} | ||
|
||
if (System.getenv('GPG_PRIVATE_KEY')) { | ||
signing { | ||
final signingKey = System.getenv('GPG_PRIVATE_KEY') ?: '' | ||
final signingPassword = System.getenv('GPG_KEY_PASSWORD') ?: '' | ||
useInMemoryPgpKeys(signingKey, signingPassword) | ||
sign publishing.publications.mavenJava | ||
} | ||
from '0.1' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/net/neoforged/elc/tests/GradleLaunchConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.neoforged.elc.tests; | ||
|
||
import net.neoforged.elc.configs.GradleLaunchConfig; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class GradleLaunchConfigTest extends RunTest { | ||
@Test | ||
public void testGradleConfig() throws Exception { | ||
assertExpectedConfig(GradleLaunchConfig.builder("EclipseLaunchConfigs") | ||
.tasks(":hello") | ||
.showConsole(false) | ||
.offlineMode(true) | ||
.args("--console=plain") | ||
.property("helloReply", "Hello from Eclipse!") | ||
.jvmArgs("-Xmx256M") | ||
.build(), "runGradle.launch"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/test/java/net/neoforged/elc/tests/JavaApplicationLaunchConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package net.neoforged.elc.tests; | ||
|
||
import net.neoforged.elc.EclipseVariables; | ||
import net.neoforged.elc.configs.JavaApplicationLaunchConfig; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class JavaApplicationLaunchConfigTest extends RunTest { | ||
@Test | ||
public void testJavaConfig() throws Exception { | ||
assertExpectedConfig(JavaApplicationLaunchConfig.builder("EclipseLaunchConfigs") | ||
.envVar("PROMPT_VALUE", EclipseVariables.prompt("Enter Something", "Some")) | ||
.envVar("CURRENT_DATE", EclipseVariables.currentDate("yyyy/MM/dd")) | ||
.vmArgs("-Xmx256M") | ||
.args("--doStuff=true") | ||
.build("net.neoforged.elc.tests.Main"), "runJava.launch"); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/test/java/net/neoforged/elc/tests/LaunchGroupConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package net.neoforged.elc.tests; | ||
|
||
import net.neoforged.elc.configs.LaunchGroup; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class LaunchGroupConfigTest extends RunTest { | ||
@Test | ||
public void testGroupConfig() throws Exception { | ||
assertExpectedConfig(LaunchGroup.builder() | ||
.entry(LaunchGroup.entry("EclipseLaunchConfigs - runGradle") | ||
.enabled(true) | ||
.adoptIfRunning(false) | ||
.mode(LaunchGroup.Mode.RUN) | ||
.action(LaunchGroup.Action.delay(2))) | ||
.entry(LaunchGroup.entry("EclipseLaunchConfigs - runTest") | ||
.enabled(true) | ||
.adoptIfRunning(false) | ||
.mode(LaunchGroup.Mode.DEBUG) | ||
.action(LaunchGroup.Action.waitForTermination())) | ||
.build(), "runGroup.launch"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.neoforged.elc.tests; | ||
|
||
import net.neoforged.elc.configs.LaunchConfig; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.xml.sax.SAXException; | ||
|
||
import javax.xml.parsers.DocumentBuilderFactory; | ||
import javax.xml.parsers.ParserConfigurationException; | ||
import javax.xml.stream.XMLStreamException; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.IOException; | ||
import java.io.StringWriter; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
public abstract class RunTest { | ||
protected final void assertExpectedConfig(LaunchConfig config, String name) throws XMLStreamException, ParserConfigurationException, IOException, SAXException { | ||
final StringWriter writer = new StringWriter(); | ||
config.write(writer); | ||
final var factory = DocumentBuilderFactory.newInstance().newDocumentBuilder(); | ||
final var original = factory.parse(new ByteArrayInputStream(writer.toString().getBytes(StandardCharsets.UTF_8))); | ||
final var in = RunTest.class.getResourceAsStream("/" + name); | ||
final var fromFile = factory.parse(in); | ||
in.close(); | ||
|
||
original.normalizeDocument(); | ||
fromFile.normalizeDocument(); | ||
Assertions.assertTrue(original.isEqualNode(fromFile), "Documents did not match!"); | ||
} | ||
} |