-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update source/plugin/project/gradle to api-8 #888
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,6 @@ Setting Up Gradle | |
|
||
.. _using-spongegradle: | ||
|
||
.. warning:: | ||
These docs were written for SpongeAPI 7 and are likely out of date. | ||
`If you feel like you can help update them, please submit a PR! <https://github.com/SpongePowered/SpongeDocs>`__ | ||
|
||
Using SpongeGradle | ||
================== | ||
|
||
|
@@ -21,85 +17,95 @@ only need to update your plugin version in one file. | |
version together with SpongeGradle_. :ref:`The Gradle section of the build systems page <gradle-setup>` explains how | ||
to setup Gradle on your computer. | ||
|
||
.. tip:: | ||
The `Sponge plugin template <https://github.com/SpongePowered/sponge-plugin-template/>`__ is a `Template repository <https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template>`__ | ||
that demonstrate SpongeGradle. | ||
|
||
Below is a simple template that should be usable for most plugins. **Make sure to replace the group with the group ID | ||
you have chosen before.** | ||
|
||
.. code-block:: groovy | ||
.. code-block:: kotlin | ||
|
||
plugins { | ||
id 'java' | ||
id 'org.spongepowered.plugin' version '0.11.3' | ||
r"""`java-library` | ||
id("org.spongepowered.gradle.plugin") version "2.0.1" | ||
} | ||
|
||
// This may not be required, but has solved issues in the past | ||
compileJava.options.encoding = 'UTF-8' | ||
|
||
// TODO: Change the following to match your information | ||
group = 'com.example' | ||
version = '1.0.0-SNAPSHOT' | ||
description = 'Here lies an example plugin definition' | ||
group = "com.example" | ||
version = "1.0.0-SNAPSHOT" | ||
|
||
repositories { | ||
jcenter() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile 'org.spongepowered:spongeapi:8.0.0' | ||
sponge { | ||
apiVersion("8.0.0") | ||
license("CHANGEME") | ||
loader { | ||
name(PluginLoaders.JAVA_PLAIN) | ||
version("1.0") | ||
} | ||
plugin("example") { | ||
description("Just testing things...") | ||
entrypoint("org.spongepowered.example.Example") | ||
} | ||
} | ||
|
||
val javaTarget = 8 // Sponge targets a minimum of Java 8 | ||
ImMorpheus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
java { | ||
sourceCompatibility = JavaVersion.toVersion(javaTarget) | ||
targetCompatibility = JavaVersion.toVersion(javaTarget) | ||
} | ||
|
||
tasks.withType(JavaCompile::class).configureEach { | ||
options.apply { | ||
encoding = "utf-8" // Consistent source file encoding | ||
if (JavaVersion.current().isJava10Compatible) { | ||
release.set(javaTarget) | ||
} | ||
} | ||
} | ||
|
||
These few lines handle most settings you would normally do manually: | ||
|
||
* Basic Gradle Java setup | ||
* Set your project to compile with Java 8 | ||
* Add Sponge's Maven repository (and Maven Central) | ||
* Set up a plugin with the project name in lower case as **plugin ID** | ||
* Automatically includes the project name, description and :doc:`version <../project/version-numbers>` in | ||
:doc:`/plugin/plugin-meta`. | ||
|
||
Manually setting the plugin ID | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
By default, the Gradle plugin will configure your **plugin ID** with project name (in lowercase) you have configured. | ||
If you want to use a custom **plugin ID** and still use the :doc:`/plugin/plugin-meta` integration you can change it | ||
manually: | ||
|
||
.. code-block:: groovy | ||
|
||
sponge { | ||
plugin { | ||
id = 'pluginidgoeshere' | ||
} | ||
} | ||
|
||
Overriding defaults | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
By default, the Gradle plugin will contribute the **plugin name**, **plugin version**, and **description** automatically | ||
to :doc:`/plugin/plugin-meta` with defaults defined in the project properties. It is also possible to override these if | ||
you want to specify them manually: | ||
|
||
.. code-block:: groovy | ||
.. code-block:: kotlin | ||
|
||
sponge { | ||
plugin { | ||
meta { | ||
name = 'Example Plugin' | ||
version = '1.0.0-SNAPSHOT' | ||
description = 'This is an example plugin' | ||
url = 'http://www.example.com/' | ||
} | ||
apiVersion("8.0.0-SNAPSHOT") | ||
license("CHANGEME") | ||
loader { | ||
name(PluginLoaders.JAVA_PLAIN) | ||
version("1.0") | ||
} | ||
} | ||
|
||
You can also remove a default value entirely: | ||
|
||
.. code-block:: groovy | ||
|
||
sponge { | ||
plugin { | ||
meta { | ||
name = null | ||
description = null | ||
plugin("example") { | ||
displayName("Example") | ||
entrypoint("org.spongepowered.example.Example") | ||
description("Just testing things...") | ||
links { | ||
homepage("https://spongepowered.org") | ||
source("https://spongepowered.org/source") | ||
issues("https://spongepowered.org/issues") | ||
} | ||
contributor("Spongie") { | ||
description("Lead Developer") | ||
Inscrutable marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
dependency("spongeapi") { | ||
loadOrder(PluginDependency.LoadOrder.AFTER) | ||
optional(false) | ||
} | ||
} | ||
} | ||
|
@@ -114,18 +120,17 @@ Without SpongeGradle | |
Generally, everything necessary to compile a Sponge plugin using Gradle can be done by simply adding the SpongeAPI | ||
dependency to your project: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not as true anymore -- you'd have to manually write out a metadata file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
.. code-block:: groovy | ||
.. code-block:: kotlin | ||
|
||
repositories { | ||
jcenter() | ||
maven { | ||
name = 'sponge-repo' | ||
url = 'https://repo.spongepowered.org/repository/maven-public/' | ||
mavenCentral() | ||
maven("https://repo.spongepowered.org/repository/maven-public/") { | ||
name = "sponge" | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'org.spongepowered:spongeapi:8.0.0' | ||
api("org.spongepowered:spongeapi:8.0.0") | ||
ImMorpheus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
.. _SpongeGradle: https://github.com/SpongePowered/SpongeGradle | ||
.. _SpongeGradle: https://github.com/SpongePowered/SpongeGradle |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r"""
?