Skip to content

Commit

Permalink
chore(deps): Update build deps and github actions (#69)
Browse files Browse the repository at this point in the history
* chore(deps): Update build deps and github actions

* fix: resolve gradle URL deprecations

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: zml <[email protected]>
  • Loading branch information
renovate[bot] and zml2008 authored Sep 9, 2023
1 parent 3ba9288 commit cbc9205
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 30 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ version = "1.0"

[versions]
indra = "3.1.3"
pluginPublish = "1.2.0"
spotless = "6.19.0"
pluginPublish = "1.2.1"
spotless = "6.21.0"
junit = "5.9.3"
mammoth = "1.3.1"

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
3 changes: 2 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,56 +24,96 @@
*/
package org.spongepowered.gradle.plugin.config;

import org.gradle.api.GradleException;
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Optional;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import javax.inject.Inject;

public class PluginLinksConfiguration {

private final Property<URL> homepage;
private final Property<URL> source;
private final Property<URL> issues;
private final Property<URI> homepage;
private final Property<URI> source;
private final Property<URI> issues;

private final Property<URL> legacyHomepage;
private final Property<URL> legacySource;
private final Property<URL> legacyIssues;

@Inject
public PluginLinksConfiguration(final ObjectFactory factory) {
this.homepage = factory.property(URL.class);
this.source = factory.property(URL.class);
this.issues = factory.property(URL.class);
this.legacyHomepage = factory.property(URL.class);
this.legacySource = factory.property(URL.class);
this.legacyIssues = factory.property(URL.class);

this.homepage = factory.property(URI.class).convention(urlToUri(this.legacyHomepage));
this.source = factory.property(URI.class).convention(urlToUri(this.legacySource));
this.issues = factory.property(URI.class).convention(urlToUri(this.legacyIssues));
}

private Provider<URI> urlToUri(final Property<URL> url) {
return url.map(old -> {
try {
return old.toURI();
} catch (final URISyntaxException ex) {
throw new GradleException("Failed to convert the provided URL to a URI, please set the URI directly", ex);
}
});
}

@Input
@Optional
public Property<URL> getHomepage() {
public Property<URI> getHomepageLink() {
return this.homepage;
}

public void homepage(final String homepage) throws MalformedURLException {
this.homepage.set(new URL(homepage));
@Deprecated
@Internal
public Property<URL> getHomepage() {
return this.legacyHomepage;
}

public void homepage(final String homepage) throws URISyntaxException {
this.homepage.set(new URI(homepage));
}

@Input
@Optional
public Property<URL> getSource() {
public Property<URI> getSourceLink() {
return this.source;
}

public void source(final String source) throws MalformedURLException {
this.source.set(new URL(source));
@Internal
@Deprecated
public Property<URL> getSource() {
return this.legacySource;
}

public void source(final String source) throws URISyntaxException {
this.source.set(new URI(source));
}

@Input
@Optional
public Property<URL> getIssues() {
public Property<URI> getIssuesLink() {
return this.issues;
}

public void issues(final String issues) throws MalformedURLException {
this.issues.set(new URL(issues));
@Deprecated
@Internal
public Property<URL> getIssues() {
return this.legacyIssues;
}

public void issues(final String issues) throws URISyntaxException {
this.issues.set(new URI(issues));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.gson.Gson;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.InvalidUserDataException;
import org.gradle.api.file.DirectoryProperty;
import org.gradle.api.provider.Property;
Expand Down Expand Up @@ -54,6 +55,7 @@
import org.spongepowered.plugin.metadata.builtin.model.StandardPluginLinks;

import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;

Expand Down Expand Up @@ -122,16 +124,20 @@ private <T extends StandardInheritable.AbstractBuilder<?, T>> T populateBuilder(

final StandardPluginLinks.Builder linksBuilder = StandardPluginLinks.builder();
final PluginLinksConfiguration linksConfiguration = src.getLinks();
if (linksConfiguration.getHomepage().isPresent()) {
linksBuilder.homepage(linksConfiguration.getHomepage().get());
}
if (linksConfiguration.getSource().isPresent()) {
linksBuilder.source(linksConfiguration.getSource().get());
}
if (linksConfiguration.getIssues().isPresent()) {
linksBuilder.issues(linksConfiguration.getIssues().get());
try {
if (linksConfiguration.getHomepageLink().isPresent()) {
linksBuilder.homepage(linksConfiguration.getHomepageLink().get().toURL());
}
if (linksConfiguration.getSourceLink().isPresent()) {
linksBuilder.source(linksConfiguration.getSourceLink().get().toURL());
}
if (linksConfiguration.getIssuesLink().isPresent()) {
linksBuilder.issues(linksConfiguration.getIssuesLink().get().toURL());
}
builder.links(linksBuilder.build());
} catch (final MalformedURLException ex) {
throw new GradleException("Failed to convert URIs back to URLs for writing to plugin meta file");
}
builder.links(linksBuilder.build());

// TODO: validate paths here?
final StandardPluginBranding.Builder brandingBuilder = StandardPluginBranding.builder();
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pluginManagement {
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
}

dependencyResolutionManagement {
Expand Down

0 comments on commit cbc9205

Please sign in to comment.