-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46d0012
commit f46aafc
Showing
17 changed files
with
518 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Parser = CommandLine.Parser; | ||
|
||
namespace Rewrite.Server; | ||
|
||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var result = new Parser(ps => | ||
{ | ||
ps.AllowMultiInstance = true; | ||
}) | ||
.ParseArguments<Options>(args); | ||
|
||
if (result.Errors.Any()) | ||
{ | ||
foreach (var resultError in result.Errors) | ||
{ | ||
|
||
Console.WriteLine(resultError); | ||
} | ||
throw new AggregateException(result.Errors.Select(e => new ArgumentException(e.ToString()))); | ||
} | ||
|
||
var options = result.Value; | ||
|
||
var server = new Server(options); | ||
|
||
server.Listen().Wait(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<PackageIcon>moderne.png</PackageIcon> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<ErrorOnDuplicatePublishOutputFiles>false</ErrorOnDuplicatePublishOutputFiles> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup Condition="'$(RELEASE_BUILD)'==''"> | ||
<ProjectReference Include="..\Rewrite.Core\Rewrite.Core.csproj" /> | ||
<ProjectReference Include="..\Rewrite.CSharp\Rewrite.CSharp.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Java\Rewrite.Java.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Json\Rewrite.Json.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Properties\Rewrite.Properties.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Xml\Rewrite.Xml.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Yaml\Rewrite.Yaml.csproj" /> | ||
<ProjectReference Include="..\Rewrite.Remote.Codec\Rewrite.Remote.Codec.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(RELEASE_BUILD)'==''"> | ||
<ProjectReference Include="$(RewriteRemoteDir)\src\Rewrite.Remote\Rewrite.Remote.csproj" /> | ||
<ProjectReference Include="$(RewriteRemoteDir)\src\Rewrite.Remote.Server\Rewrite.Remote.Server.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="'$(RELEASE_BUILD)'!=''"> | ||
<PackageReference Include="Rewrite.Remote" Version="$(RewriteRemoteVersion)"/> | ||
<PackageReference Include="Rewrite.Remote.Server" Version="$(RewriteRemoteVersion)"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CommandLineParser" Version="2.9.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build/ | ||
target/ | ||
.gradle/ | ||
.idea/ | ||
out/ | ||
bin/ | ||
src/main/generated/ |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
plugins { | ||
id("org.openrewrite.build.language-library") | ||
} | ||
|
||
tasks.register<Zip>("zipDotnetServer") { | ||
archiveFileName.set("DotnetServer.zip") | ||
destinationDirectory.set(layout.buildDirectory.dir("tmp")) | ||
from(rootProject.file("Rewrite/src/Rewrite.Server/bin/Release/net8.0/publish")) | ||
include("*") | ||
include("*/*") //to include contents of a folder present inside Reports directory | ||
} | ||
|
||
tasks.processResources { | ||
dependsOn("zipDotnetServer") | ||
from(layout.buildDirectory.file("tmp/DotnetServer.zip")) | ||
} | ||
|
||
tasks.compileJava { | ||
options.release = 8 | ||
} | ||
|
||
// We don't care about publishing javadocs anywhere, so don't waste time building them | ||
tasks.withType<Javadoc>().configureEach { | ||
enabled = false | ||
} | ||
|
||
tasks.named<Jar>("sourcesJar") { | ||
enabled = false | ||
} | ||
|
||
tasks.named<Jar>("javadocJar") { | ||
enabled = false | ||
} | ||
|
||
val emptySourceJar = tasks.create<Jar>("emptySourceJar") { | ||
file("README.md") | ||
archiveClassifier.set("sources") | ||
} | ||
|
||
val emptyJavadocJar = tasks.create<Jar>("emptyJavadocJar") { | ||
file("README.md") | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
publishing { | ||
publications.named<MavenPublication>("nebula") { | ||
artifactId = project.name | ||
description = project.description | ||
|
||
artifacts.clear() // remove the regular JAR | ||
// Empty JARs are OK: https://central.sonatype.org/publish/requirements/#supply-javadoc-and-sources | ||
artifact(tasks.named("jar")) | ||
artifact(emptySourceJar) | ||
artifact(emptyJavadocJar) | ||
|
||
pom { | ||
name.set(project.name) | ||
description.set(project.description) | ||
url.set("https://moderne.io") | ||
licenses { | ||
license { | ||
name.set("Moderne, Inc. Commercial License") | ||
url.set("https://docs.moderne.io/administrator-documentation/references/licensing") | ||
} | ||
} | ||
developers { | ||
developer { | ||
name.set("Team Moderne") | ||
email.set("[email protected]") | ||
organization.set("Moderne, Inc.") | ||
organizationUrl.set("https://moderne.io") | ||
} | ||
} | ||
scm { | ||
connection.set("scm:git:git://github.com/moderneinc/rewrite-remote.git") | ||
developerConnection.set("scm:git:ssh://github.com:moderneinc/rewrite-remote.git") | ||
url.set("https://github.com/moderneinc/rewrite-remote/tree/main") | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
rewrite-csharp-remote-server/src/main/resources/logback.xml
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright 2021 the original author or authors. | ||
<p> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
<p> | ||
https://www.apache.org/licenses/LICENSE-2.0 | ||
<p> | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<configuration> | ||
|
||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="info"> | ||
<appender-ref ref="CONSOLE"/> | ||
</root> | ||
|
||
</configuration> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
root = true | ||
|
||
# Limit continuation indent to 2 spaces for Java files, as we heavily use continuations around our text blocks. | ||
[*.java] | ||
indent_size = 4 | ||
ij_continuation_indent_size = 2 |
91 changes: 91 additions & 0 deletions
91
...-csharp-remote-server/src/test/java/org/openrewrite/remote/csharp/ProjectParsingTest.java
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 |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.openrewrite.remote.csharp; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import org.openrewrite.Cursor; | ||
import org.openrewrite.InMemoryExecutionContext; | ||
import org.openrewrite.remote.RemotingProjectParser; | ||
import org.openrewrite.scheduling.WatchableExecutionContext; | ||
|
||
public class ProjectParsingTest { | ||
|
||
@Test | ||
public void testParse() { | ||
WatchableExecutionContext ctx = | ||
new WatchableExecutionContext(new InMemoryExecutionContext()); | ||
|
||
int port = ThreadLocalRandom.current().nextInt(50000, 65535); | ||
try (DotNetRemotingServerEngine server = DotNetRemotingServerEngine.create(DotNetRemotingServerEngine.Config.builder() | ||
.extractedDotnetBinaryDir(Paths.get(System.getProperty("java.io.tmpdir"))) | ||
.port(port) | ||
.logFilePath(Paths.get("./build/test.log").toAbsolutePath().toString()) | ||
.build())) { | ||
|
||
server.start(); | ||
var client = new RemotingProjectParser(server); | ||
|
||
Path pathToSolution = Path.of(Thread.currentThread() | ||
.getContextClassLoader() | ||
.getResource( | ||
"ModerneHelloWorld/ModerneHelloWorld.sln") | ||
.getPath()); | ||
client.findAllProjects(pathToSolution, ctx) | ||
.forEach(proj -> client.parseProjectSources(proj, | ||
pathToSolution, | ||
pathToSolution.getParent(), | ||
ctx) | ||
.forEach(sf -> { | ||
System.out.println(sf.print(new Cursor(new Cursor( | ||
null, | ||
Cursor.ROOT_VALUE), sf))); | ||
})); | ||
} | ||
} | ||
|
||
@Test | ||
public void testThrowExceptionOnIncorrectDotnetPath() { | ||
int port = ThreadLocalRandom.current().nextInt(50000, 65535); | ||
try (DotNetRemotingServerEngine server = DotNetRemotingServerEngine.create(DotNetRemotingServerEngine.Config.builder().dotnetExecutable("dotnet1").extractedDotnetBinaryDir( | ||
Paths.get(System.getProperty("java.io.tmpdir"))).port(port).build())) { | ||
assertThatThrownBy(server::start) | ||
.isInstanceOf(IOException.class); | ||
} | ||
} | ||
|
||
@Test | ||
public void testThrowExceptionOnIncorrectRunnable() { | ||
int port = ThreadLocalRandom.current().nextInt(50000, 65535); | ||
try (DotNetRemotingServerEngine server = DotNetRemotingServerEngine.create(DotNetRemotingServerEngine.Config.builder() | ||
.extractedDotnetBinaryDir(Paths.get(System.getProperty("java.io.tmpdir"))) | ||
.dotnetServerDllName("Rewrite.Server1.dll") | ||
.port(port) | ||
.build())) { | ||
assertThatThrownBy(server::start) | ||
.isInstanceOf(IllegalStateException.class); | ||
} | ||
} | ||
} |
Oops, something went wrong.