-
-
Notifications
You must be signed in to change notification settings - Fork 3
Add multi-release optimised methods for LogUtils #10
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
Open
PaintNinja
wants to merge
3
commits into
MinecraftForge:master
Choose a base branch
from
PaintNinja:logging-multirelease
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
24 changes: 24 additions & 0 deletions
24
log-utils/src/java11/java/net/minecraftforge/util/logging/MultiReleaseMethods.java
This file contains hidden or 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,24 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
package net.minecraftforge.util.logging; | ||
PaintNinja marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Utility class for methods that are exclusively used in multi-release form. (Java 11+) | ||
*/ | ||
final class MultiReleaseMethods { | ||
static final String INDENT_STRING = " "; | ||
|
||
static <K, V> Map.Entry<K, V> mapEntry(K key, V value) { | ||
return Map.entry(key, value); | ||
} | ||
|
||
static String getIndentation(byte indent) { | ||
return INDENT_STRING.repeat(indent); | ||
} | ||
|
||
private MultiReleaseMethods() { } | ||
} |
This file contains hidden or 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
29 changes: 29 additions & 0 deletions
29
log-utils/src/main/java/net/minecraftforge/util/logging/MultiReleaseMethods.java
This file contains hidden or 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 @@ | ||
/* | ||
* Copyright (c) Forge Development LLC | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
package net.minecraftforge.util.logging; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Utility class for methods that are exclusively used in multi-release form. (Java 8) | ||
*/ | ||
final class MultiReleaseMethods { | ||
static final String INDENT_STRING = " "; | ||
|
||
static <K, V> Map.Entry<K, V> mapEntry(K key, V value) { | ||
return new AbstractMap.SimpleImmutableEntry<>(key, value); | ||
} | ||
|
||
static String getIndentation(byte indent) { | ||
StringBuilder builder = new StringBuilder(INDENT_STRING.length() * indent); | ||
for (int i = 0; i < indent; i++) { | ||
builder.append(INDENT_STRING); | ||
} | ||
return builder.toString(); | ||
} | ||
|
||
private MultiReleaseMethods() { } | ||
} |
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.
SourceSets for multi-release jars dont work in a lot of ides (anything except intellij) so the proper way to do it is to have the java11 code in a sub project.
Uh oh!
There was an error while loading. Please reload this page.
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.
That is fine. I've seen this done in several different ways so I want to make sure that we just stay consistent moving forward, and I'd like to do it in a way that is as Gradle-friendly as possible.
So, my thinking for the main project is this:
Then, in each of the subprojects, depend on
implementation rootProject
.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.
The code block is just a sketch, I'd probably use whatever the cleanest solution is. I'm sure there is a way to reference a subproject with respect to the current project (i.e.
subprojects['java-11'] = project(':log-utils:java-11')
).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.
Im fine with whatever way gradle wants it to be done.
I dont know how to do cross project merging.
But because non-intellij (yes, eclipse) IDEs dont separate dependencies/java deps on a sourceset level it is better to split everything into sub-projects.
Similar to how i've split AccessTransformer/ModLauncher/SecureModules (etc) tests into sub projects.
So ya, sub-projects rather then sourcesets if it is a different set of dependencies/java targets.