Skip to content

Commit

Permalink
Merge pull request #3 from NotMyFault/main
Browse files Browse the repository at this point in the history
Don't fail building on modern Java
  • Loading branch information
NotMyFault authored Aug 25, 2021
1 parent f580258 commit 71842d4
Show file tree
Hide file tree
Showing 11 changed files with 1,816 additions and 26 deletions.
1,013 changes: 1,013 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "validate gradle wrapper"

on: ["pull_request", "push"]

jobs:
build:
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2.3.4"
- name: "Validate Gradle Wrapper"
uses: "gradle/wrapper-validation-action@v1.0.4"
17 changes: 17 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "build"

on: ["pull_request", "push"]

jobs:
build:
runs-on: "ubuntu-20.04"
steps:
- name: "Checkout Repository"
uses: "actions/checkout@v2.3.4"
- name: "Setup JDK 16"
uses: "actions/setup-java@v2.2.0"
with:
distribution: "temurin"
java-version: "16"
- name: "Clean Build"
run: "./gradlew clean build"
22 changes: 22 additions & 0 deletions HEADER.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
_____ _
| __ \ | |
| |__) |_ _ ___| |_ ___ _ __
| ___/ _` / __| __/ _ \ '__|
| | | (_| \__ \ || __/ |
|_| \__,_|___/\__\___|_|

Paste service used to submit data to the IncendoPasteViewer
Copyright (C) 2021 IntellectualSites

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ Used in the projects [FastAsyncWorldEdit](https://github.com/IntellectualSites/F
```kotlin
repositories {
maven {
name = "IntellectualSites' Snapshots"
url = uri("https://mvn.intellectualsites.com/content/repositories/snapshots/")
name = "IntellectualSites"
url = uri("https://mvn.intellectualsites.com/content/groups/public/")
}
}

dependencies {
implementation("com.intellectualsites.paster:Paster:1.0.1-SNAPSHOT")
implementation("com.intellectualsites.paster:Paster:1.1.0")
}
```

- [Javadocs](https://ci.athion.net/job/Paster/javadoc/)
You need to shade Paster into your software by either using maven shade or gradle shadow.
32 changes: 25 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import org.cadixdev.gradle.licenser.LicenseExtension

plugins {
java
`java-library`
`maven-publish`

id("org.cadixdev.licenser") version "0.6.1"
}

configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = sourceCompatibility
the<JavaPluginExtension>().toolchain {
languageVersion.set(JavaLanguageVersion.of(16))
}

group = "com.intellectualsites.paster"
version = "1.0.2-SNAPSHOT"
version = "1.1.0"

repositories {
mavenCentral()
}

dependencies {
compileOnlyApi("com.google.code.gson:gson:2.8.0")
compileOnlyApi("com.google.guava:guava:21.0")
compileOnlyApi("com.google.code.findbugs:jsr305:3.0.2")
}

repositories {
mavenCentral()
configure<LicenseExtension> {
header.set(resources.text.fromFile(file("HEADER.txt")))
newLine.set(false)
}

val javadocDir = rootDir.resolve("docs").resolve("javadoc").resolve(project.name)
val javadocDir = rootDir.resolve("docs").resolve("javadoc")
tasks {
val assembleTargetDir = create<Copy>("assembleTargetDirectory") {
destinationDir = rootDir.resolve("target")
Expand All @@ -47,6 +55,7 @@ tasks {
options.compilerArgs.add("-Xlint:$disabledLint")
options.isDeprecation = true
options.encoding = "UTF-8"
options.release.set(11)
}

javadoc {
Expand All @@ -57,6 +66,7 @@ tasks {
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
opt.links("https://javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/")
opt.destinationDirectory = javadocDir
}
}
Expand All @@ -73,6 +83,14 @@ publishing {

pom {

licenses {
license {
name.set("GNU General Public License, Version 3.0")
url.set("https://www.gnu.org/licenses/gpl-3.0.html")
distribution.set("repo")
}
}

developers {
developer {
id.set("Sauilitired")
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Empty file modified gradlew
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"config:base"
]
}
56 changes: 43 additions & 13 deletions src/main/java/com/intellectualsites/paster/IncendoPaster.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* _____ _
* | __ \ | |
* | |__) |_ _ ___| |_ ___ _ __
* | ___/ _` / __| __/ _ \ '__|
* | | | (_| \__ \ || __/ |
* |_| \__,_|___/\__\___|_|
*
* Paste service used to submit data to the IncendoPasteViewer
* Copyright (C) 2021 IntellectualSites
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.intellectualsites.paster;

import com.google.common.base.Charsets;
Expand Down Expand Up @@ -28,6 +52,7 @@
import java.util.concurrent.TimeUnit;

public class IncendoPaster {

/**
* Upload service URL
*/
Expand All @@ -36,7 +61,7 @@ public class IncendoPaster {
* Valid paste applications
*/
public static final Collection<String> VALID_APPLICATIONS =
Arrays.asList("plotsquared", "fastasyncworldedit", "incendopermissions", "kvantum");
Arrays.asList("plotsquared", "fastasyncworldedit", "incendopermissions", "kvantum");

private final Collection<PasteFile> files = new ArrayList<>();
private final String pasteApplication;
Expand Down Expand Up @@ -65,7 +90,8 @@ public IncendoPaster(final String pasteApplication) {
* @return URL of the paste
* @throws IOException if upload failed
*/
public static String debugPaste(@Nonnull File logFile, @Nullable String debugInfo, @Nullable File... extraFiles) throws IOException {
public static String debugPaste(@Nonnull File logFile, @Nullable String debugInfo, @Nullable File... extraFiles) throws
IOException {
return debugPaste(logFile, debugInfo, extraFiles == null ? null : Arrays.asList(extraFiles));
}

Expand All @@ -79,20 +105,20 @@ public static String debugPaste(@Nonnull File logFile, @Nullable String debugInf
* @throws IOException if upload failed
*/
public static String debugPaste(@Nonnull File logFile, @Nullable String debugInfo, @Nullable List<File> extraFiles)
throws IOException {
throws IOException {
final IncendoPaster incendoPaster = new IncendoPaster("fastasyncworldedit");

StringBuilder b = new StringBuilder();
b.append(
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
+ "problem\n");
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
+ "problem\n");
b.append("\n# Server Information\n");
b.append(debugInfo);
b.append("\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime();
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
b.append("Uptime: ").append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS)).append(" minutes")
.append('\n');
.append('\n');
b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n');
b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024).append(" MB").append('\n');
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024).append(" MB").append('\n');
Expand Down Expand Up @@ -155,8 +181,9 @@ private static String readFile(final File file, boolean cleanIPs) throws IOExcep
String contentStr = content.toString();
if (cleanIPs) {
contentStr = contentStr.replaceAll(
"\\b(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\b",
"*");
"\\b(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\.(1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])\\b",
"*"
);
}
return contentStr;
}
Expand All @@ -175,7 +202,7 @@ public void addFile(File file) throws IOException {
}

public void addFile(File file, @Nullable String name) throws IOException {
String fileName = name != null ? name : file.getName();
String fileName = name != null ? name : file.getName();
boolean cleanIPS = fileName.endsWith(".log") || fileName.endsWith(".txt") || !fileName.contains(".");
addFile(new PasteFile(fileName, readFile(file, cleanIPS)));
}
Expand Down Expand Up @@ -219,7 +246,7 @@ private String toJsonString() {
while (fileIterator.hasNext()) {
final PasteFile file = fileIterator.next();
builder.append("\"file-").append(file.getFileName()).append("\": \"")
.append(file.getContent().replaceAll("\"", "\\\\\"")).append("\"");
.append(file.getContent().replaceAll("\"", "\\\\\"")).append("\"");
if (fileIterator.hasNext()) {
builder.append(",\n");
}
Expand Down Expand Up @@ -250,12 +277,13 @@ public final String upload() throws Throwable {
}
if (!httpURLConnection.getResponseMessage().contains("OK")) {
throw new IllegalStateException(String
.format("Server returned status: %d %s", httpURLConnection.getResponseCode(),
httpURLConnection.getResponseMessage()));
.format("Server returned status: %d %s", httpURLConnection.getResponseCode(),
httpURLConnection.getResponseMessage()
));
}
final StringBuilder input = new StringBuilder();
try (final BufferedReader inputStream = new BufferedReader(
new InputStreamReader(httpURLConnection.getInputStream()))) {
new InputStreamReader(httpURLConnection.getInputStream()))) {
String line;
while ((line = inputStream.readLine()) != null) {
input.append(line).append("\n");
Expand Down Expand Up @@ -307,5 +335,7 @@ public String getFileName() {
public String getContent() {
return this.content;
}

}

}

0 comments on commit 71842d4

Please # to comment.