Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions CommunityToolkit.Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.12.35101.237
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{899F0713-7FC6-4750-BAFC-AC650B35B453}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{414151D4-7009-4E78-A5C6-D99EBD1E67D1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Hosting.Java", "src\CommunityToolkit.Aspire.Hosting.Java\CommunityToolkit.Aspire.Hosting.Java.csproj", "{DAA67050-44B3-458F-9818-5877D606866A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.AppHost.Tests", "test\CommunityToolkit.Aspire.AppHost.Tests\CommunityToolkit.Aspire.AppHost.Tests.csproj", "{E2905A71-E25D-46FC-A128-D6A366D4D751}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8519CC01-1370-47C8-AD94-B0F326B1563F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Hosting.Java.Tests", "test\CommunityToolkit.Aspire.Hosting.Java.Tests\CommunityToolkit.Aspire.Hosting.Java.Tests.csproj", "{2EA0F32C-F21B-4D29-8018-7E96363E4548}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "java", "java", "{F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8519CC01-1370-47C8-AD94-B0F326B1563F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Java.WebApp", "examples\java\CommunityToolkit.Aspire.Java.WebApp\CommunityToolkit.Aspire.Java.WebApp.csproj", "{3D767C8C-7E04-4264-B4E9-13600650D2B1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Java.ApiApp", "examples\java\CommunityToolkit.Aspire.Java.ApiApp\CommunityToolkit.Aspire.Java.ApiApp.csproj", "{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "java", "java", "{F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Java.AppHost", "examples\java\CommunityToolkit.Aspire.Java.AppHost\CommunityToolkit.Aspire.Java.AppHost.csproj", "{55AC8E7E-DA0A-489D-8059-4E7190C9EEBF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Java.ServiceDefaults", "examples\java\CommunityToolkit.Aspire.Java.ServiceDefaults\CommunityToolkit.Aspire.Java.ServiceDefaults.csproj", "{BBAFA814-1026-4A39-AA28-BCAE3951A224}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.Java.WebApp", "examples\java\CommunityToolkit.Aspire.Java.WebApp\CommunityToolkit.Aspire.Java.WebApp.csproj", "{3D767C8C-7E04-4264-B4E9-13600650D2B1}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{899F0713-7FC6-4750-BAFC-AC650B35B453}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Aspire.AppHost.Tests", "test\CommunityToolkit.Aspire.AppHost.Tests\CommunityToolkit.Aspire.AppHost.Tests.csproj", "{E2905A71-E25D-46FC-A128-D6A366D4D751}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -33,14 +33,10 @@ Global
{DAA67050-44B3-458F-9818-5877D606866A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAA67050-44B3-458F-9818-5877D606866A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAA67050-44B3-458F-9818-5877D606866A}.Release|Any CPU.Build.0 = Release|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Release|Any CPU.Build.0 = Release|Any CPU
{2EA0F32C-F21B-4D29-8018-7E96363E4548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EA0F32C-F21B-4D29-8018-7E96363E4548}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EA0F32C-F21B-4D29-8018-7E96363E4548}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EA0F32C-F21B-4D29-8018-7E96363E4548}.Release|Any CPU.Build.0 = Release|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Release|Any CPU.Build.0 = Release|Any CPU
{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -53,22 +49,22 @@ Global
{BBAFA814-1026-4A39-AA28-BCAE3951A224}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BBAFA814-1026-4A39-AA28-BCAE3951A224}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BBAFA814-1026-4A39-AA28-BCAE3951A224}.Release|Any CPU.Build.0 = Release|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D767C8C-7E04-4264-B4E9-13600650D2B1}.Release|Any CPU.Build.0 = Release|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2905A71-E25D-46FC-A128-D6A366D4D751}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{E2905A71-E25D-46FC-A128-D6A366D4D751} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{2EA0F32C-F21B-4D29-8018-7E96363E4548} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{DAA67050-44B3-458F-9818-5877D606866A} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{3D767C8C-7E04-4264-B4E9-13600650D2B1} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{34602A2D-24B2-47C0-9678-F1F7CD6C8C6D} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{55AC8E7E-DA0A-489D-8059-4E7190C9EEBF} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{BBAFA814-1026-4A39-AA28-BCAE3951A224} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{3D767C8C-7E04-4264-B4E9-13600650D2B1} = {F120E99A-FB2A-4C3B-B588-9B7ED1CD4E8A}
{E2905A71-E25D-46FC-A128-D6A366D4D751} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08B1D4B8-D2C5-4A64-BB8B-E1A2B29525F0}
Expand Down
Binary file added agents/opentelemetry-javaagent.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<AssemblyName>CommunityToolkit.Aspire.Java.AppHost</AssemblyName>
<RootNamespace>CommunityToolkit.Aspire.Java.AppHost</RootNamespace>

<JavaAppRoot>$(MSBuildProjectDirectory)/../CommunityToolkit.Aspire.Java.Spring.Maven</JavaAppRoot>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,4 +22,9 @@
<ProjectReference Include="..\CommunityToolkit.Aspire.Java.WebApp\CommunityToolkit.Aspire.Java.WebApp.csproj" />
</ItemGroup>

<Target Name="PublishRunWebpack" AfterTargets="Build">
<!-- As part of publishing, ensure the Java app is freshly built -->
<Exec WorkingDirectory="$(JavaAppRoot)" Command="./mvnw clean package" />
</Target>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
if (builder.ExecutionContext.IsPublishMode == false)
{
executableapp = builder.AddSpringApp("executableapp",
workingDirectory: "../CommunityToolkit.Aspire.Spring.Maven",
workingDirectory: "../CommunityToolkit.Aspire.Java.Spring.Maven",
new JavaAppExecutableResourceOptions()
{
ApplicationName = "target/spring-maven-0.0.1-SNAPSHOT.jar",
Port = 8085,
OtelAgentPath = "../../agents",
OtelAgentPath = "../../../agents",
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<base href="/" />
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="CommunityToolkit.Aspire.WebApp.styles.css" />
<link rel="stylesheet" href="CommunityToolkit.Aspire.Java.WebApp.styles.css" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">CommunityToolkit.Aspire.WebApp</a>
<a class="navbar-brand" href="">CommunityToolkit.Aspire.Java.WebApp</a>
</div>
</div>

Expand Down
5 changes: 5 additions & 0 deletions global.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for the global.json file? Are you hitting problems?

Copy link
Contributor Author

@justinyoo justinyoo Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not using the preview version of .NET SDK, which might cause unwanted side effects.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"allowPrerelease": false
}
}
50 changes: 30 additions & 20 deletions src/CommunityToolkit.Aspire.Hosting.Java/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
# Aspire Contribs
# CommunityToolkit.Aspire.Hosting.Java

This is a collection of community contributed libraries for .NET Aspire
This enables either containerised or executable Java app to be integrated with .NET Aspire.

## Prerequisites

- [JDK 17+](https://learn.microsoft.com/java/openjdk/download)
- [Springboot CLI](https://docs.spring.io/spring-boot/installing.html#getting-started.installing.cli)
- [Apache Maven](https://maven.apache.org)
- [Docker](https://docs.docker.com/get-docker/)
- [JDK 17+](https://learn.microsoft.com/java/openjdk/download)
- [Springboot CLI](https://docs.spring.io/spring-boot/installing.html#getting-started.installing.cli)
- [Apache Maven](https://maven.apache.org)
- [Docker](https://docs.docker.com/get-docker/)

## For Java App
## Quickstart

1. First of all, you should have [OpenTelemetry Agent for Java](https://opentelemetry.io/docs/zero-code/java/agent/). You can download it to your local machine by running the following commands:
1. Run .NET Aspire dashboard:

```bash
# Bash
dotnet watch run --project ./examples/java/CommunityToolkit.Aspire.Java.AppHost
```

## More detailed steps (Optional)

1. Download [OpenTelemetry Agent for Java](https://opentelemetry.io/docs/zero-code/java/agent/) to your local machine by running the following commands:

```bash
# bash/zsh
mkdir -p ./agents
wget -P ./agents \
https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar

# PowerShell
New-item -type Directory -Path ./downloaded -Force
New-item -type Directory -Path ./agents -Force
Invoke-WebRequest `
-OutFile "./agents/opentelemetry-javaagent.jar" `
-Uri "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar"
Expand All @@ -29,7 +37,7 @@ This is a collection of community contributed libraries for .NET Aspire
1. Build the Spring app with Maven:

```bash
pushd ./src/CommunityToolkit.Aspire.Spring.Maven
pushd ./examples/java/CommunityToolkit.Aspire.Java.Spring.Maven

./mvnw clean package

Expand All @@ -39,27 +47,23 @@ This is a collection of community contributed libraries for .NET Aspire
1. Build a container image for the Spring app:

```bash
pushd ./src/CommunityToolkit.Aspire.Spring.Maven
pushd ./examples/java/CommunityToolkit.Aspire.Java.Spring.Maven

docker build . -t aspire-spring-maven-sample:latest

popd
```

1. Push the container image to [Docker Hub](https://hub.docker.com) under your organisation. This sample uses `aliencube`:
1. Push the container image to [Docker Hub](https://hub.docker.com) under your organisation, `contoso` for example:

```bash
docker tag aspire-spring-maven-sample:latest aliencube/aspire-spring-maven-sample:latest
docker push aliencube/aspire-spring-maven-sample:latest
docker tag aspire-spring-maven-sample:latest contoso/aspire-spring-maven-sample:latest
docker push contoso/aspire-spring-maven-sample:latest
```

> **NOTE**: You need to log in to Docker Hub before pushing the image.

1. Run .NET Aspire dashboard:

```bash
dotnet watch run --project ./src/CommunityToolkit.Aspire.AppHost
```
## Dashboard

1. Check the dashboard that both containerised app and executable app are up and running.

Expand All @@ -71,6 +75,12 @@ This is a collection of community contributed libraries for .NET Aspire

## Deployment to Azure

1. Change the directory to `examples/java`.

```bash
cd ./examples/java
```

1. Get the Azure environment name ready:

```bash
Expand Down

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions test/CommunityToolkit.Aspire.Hosting.Java.Tests/Program.cs

This file was deleted.