Skip to content

Commit

Permalink
Upgrade dependencies, locate all files entering refactoring relative …
Browse files Browse the repository at this point in the history
…to the root gradle project, mirroring the fix for openrewrite/rewrite-maven-plugin#72
  • Loading branch information
sambsnyd committed Dec 14, 2020
1 parent f72d4b3 commit 3ad667f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dependencies {
plugin("org.openrewrite:rewrite-java:latest.release")

plugin("io.micrometer.prometheus:prometheus-rsocket-client:latest.release")
plugin("io.rsocket:rsocket-transport-netty:1.0.0")
plugin("io.rsocket:rsocket-transport-netty:latest.release")

implementation("org.openrewrite:rewrite-java-11:latest.release")
implementation("org.openrewrite:rewrite-java-8:latest.release")
Expand All @@ -79,7 +79,7 @@ dependencies {
api("org.openrewrite:rewrite-java:latest.release")
api("org.eclipse.jgit:org.eclipse.jgit:latest.release")
api("io.micrometer.prometheus:prometheus-rsocket-client:latest.release")
api("io.rsocket:rsocket-transport-netty:1.0.0")
api("io.rsocket:rsocket-transport-netty:latest.release")

testImplementation(gradleTestKit())
testImplementation("org.codehaus.groovy:groovy-all:2.5.10")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected Collection<Change> listChanges() {
.map(File::toPath)
.collect(toList());

Path projectDir = getProject().getProjectDir().toPath();
Path projectDir = getProject().getRootProject().getProjectDir().toPath();

sourceFiles.addAll(JavaParser.fromJavaVersion()
.classpath(dependencyPaths)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.time.Duration;
import java.util.Base64;

import static io.rsocket.transport.netty.UriUtils.getPort;
import static org.openrewrite.gradle.RewriteMetricsPlugin.getPort;

public class MeterRegistryProvider implements AutoCloseable {
private final Logger log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
import java.net.URI;
import java.time.Duration;
import java.util.Base64;

import static io.rsocket.transport.netty.UriUtils.getPort;
import java.util.Objects;

/**
* Coordinates the publication of metrics for each rewrite plugin and each subproject along with general purpose metrics
Expand Down Expand Up @@ -89,6 +88,7 @@ private void connectToPrometheusProxy(Project project) {
case "ephemeral":
case "https":
case "wss": {

TcpClient tcpClient = TcpClient.create().secure().host(uri.getHost()).port(getPort(uri, 443));
clientTransport = websocketClientTransport(tcpClient);
break;
Expand Down Expand Up @@ -148,6 +148,20 @@ private ClientTransport websocketClientTransport(TcpClient tcpClient) {
return WebsocketClientTransport.create(httpClient, "/");
}

/**
* Returns the port of a URI. If the port is unset (i.e. {@code -1}) then returns the {@code
* defaultPort}.
*
* @param uri the URI to extract the port from
* @param defaultPort the default to use if the port is unset
* @return the port of a URI or {@code defaultPort} if unset
* @throws NullPointerException if {@code uri} is {@code null}
*/
static int getPort(URI uri, int defaultPort) {
Objects.requireNonNull(uri, "uri must not be null");
return uri.getPort() == -1 ? defaultPort : uri.getPort();
}

Iterable<Tag> getExtraTags() {
return extension.getExtraMetricsTags();
}
Expand Down

0 comments on commit 3ad667f

Please sign in to comment.