Skip to content

Commit

Permalink
typespec submodule (#2937)
Browse files Browse the repository at this point in the history
  • Loading branch information
weidongxu-microsoft committed Sep 10, 2024
1 parent 1b01ff5 commit 0b06a0b
Show file tree
Hide file tree
Showing 671 changed files with 16,316 additions and 79,989 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,7 @@ typespec-tests/package-lock.json

# ApiView properties files
/typespec-tests/src/main/resources/META-INF/*apiview_properties.json

# typespec-extension
/typespec-extension/src
/typespec-extension/generator
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "core"]
path = core
url = https://github.com/microsoft/typespec.git
39 changes: 33 additions & 6 deletions Build-TypeSpec.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
mvn clean install -P local,tsp -DskipTests "-Djacoco.skip"
$ErrorActionPreference = "Stop"

Write-Host "Apply diff to core"
Push-Location ./core
try {
git checkout .
git apply ../core.diff --ignore-whitespace
} finally {
Pop-Location
}

Write-Host "Build JAR"
mvn clean install -P tsp --no-transfer-progress
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}

Write-Host "Copy JAR and TypeSpec code to './typespec-extension' directory"
# Copy JAR
New-Item -ItemType File -Path ./typespec-extension/generator/http-client-generator/target/emitter.jar -Force
Copy-Item ./core/packages/http-client-java/generator/http-client-generator/target/emitter.jar ./typespec-extension/generator/http-client-generator/target/emitter.jar -Force
# Copy TypeScript code
Copy-Item -Path ./core/packages/http-client-java/emitter/src -Destination ./typespec-extension/ -Recurse -Force

Write-Host "Build and Pack typespec-java"
Push-Location ./typespec-extension/
try {
npm ci
npm run build
npm run lint
npm pack
npm ci
npm run build
npm run lint
# npm run check-format
npm pack
if ($LASTEXITCODE -ne 0) {
exit $LASTEXITCODE
}
}
finally {
Pop-Location
Pop-Location
}
44 changes: 12 additions & 32 deletions Generate-TypeSpec.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,20 @@ param (
)

function invokeExpressionAndCaptureOutput([string]$expression) {
$output = Invoke-Expression $expression
if ($LASTEXITCODE -ne 0) {
$ExitCode = $LASTEXITCODE
$output = Invoke-Expression $expression
if ($LASTEXITCODE -ne 0) {
$ExitCode = $LASTEXITCODE

Write-Host $output
Write-Host $output

exit $ExitCode
}
}

Write-Host "Changing directory to './typespec-extension'"
Push-Location ./typespec-extension

try {
Write-Host "Installing dependencies for TypeSpec Java ('npm ci')"
invokeExpressionAndCaptureOutput("npm ci")

Write-Host "Building TypeSpec Java ('npm run build')"
invokeExpressionAndCaptureOutput("npm run build")

Write-Host "Linting TypeSpec Java ('npm run lint')"
invokeExpressionAndCaptureOutput("npm run lint")
exit $ExitCode
}

Write-Host "Checking TypeSpec Java format ('npm run check-format')"
invokeExpressionAndCaptureOutput("npm run check-format")

Write-Host "Packing TypeSpec Java ('npm pack')"
invokeExpressionAndCaptureOutput("npm pack")

Write-Host "Returning to root directory ('..')"
} finally {
Pop-Location
Write-Host $output
}

pwsh ./Build-TypeSpec.ps1

Write-Host "Installing TypeSpec ('npm install -g @typespec/compiler')"
invokeExpressionAndCaptureOutput("npm install -g @typespec/compiler")

Expand All @@ -56,10 +36,10 @@ Push-Location ./typespec-tests

try {
Write-Host "Generating code ('Generate.ps1' in './typespec-tests')"
invokeExpressionAndCaptureOutput("./Generate.ps1 -Parallelization $Parallelization")
pwsh ./Generate.ps1 -Parallelization $Parallelization

Write-Host "Checking format of generated code ('npm run check-format')"
invokeExpressionAndCaptureOutput("npm run check-format")
# Write-Host "Checking format of generated code ('npm run check-format')"
# invokeExpressionAndCaptureOutput("npm run check-format")
} finally {
Pop-Location
}
3 changes: 3 additions & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@
<suppress checks="[ConstantName|MethodName]" files="com[/\\]azure[/\\]autorest[/\\]fluent[/\\]model[/\\]FluentType.java"/>
<!-- androidgen -->
<suppress checks="[a-zA-Z0-9]*" files="com[/\\]azure[/\\]autorest[/\\]android[/\\].*"/>

<!-- com.microsoft.typespec -->
<suppress checks="[a-zA-Z0-9]*" files="com[/\\]microsoft[/\\]typespec[/\\].*"/>
</suppressions>
1 change: 1 addition & 0 deletions core
Submodule core added at 99abec
74 changes: 74 additions & 0 deletions core.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts
index 263da6dd..121a62f2 100644
--- a/packages/http-client-java/emitter/src/code-model-builder.ts
+++ b/packages/http-client-java/emitter/src/code-model-builder.ts
@@ -240,7 +240,7 @@ export class CodeModelBuilder {
}

public async build(): Promise<CodeModel> {
- this.sdkContext = await createSdkContext(this.emitterContext, "@typespec/http-client-java", {
+ this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-java", {
versioning: { previewStringRegex: /$/ },
}); // include all versions and do the filter by ourselves

diff --git a/packages/http-client-java/emitter/src/emitter.ts b/packages/http-client-java/emitter/src/emitter.ts
index b3527bd6..1130efff 100644
--- a/packages/http-client-java/emitter/src/emitter.ts
+++ b/packages/http-client-java/emitter/src/emitter.ts
@@ -98,7 +98,7 @@ const EmitterOptionsSchema: JSONSchemaType<EmitterOptions> = {
};

export const $lib = createTypeSpecLibrary({
- name: "@typespec/http-client-java",
+ name: "@azure-tools/typespec-java",
diagnostics: {},
emitter: {
options: EmitterOptionsSchema,
diff --git a/packages/http-client-java/generator/http-client-generator-core/pom.xml b/packages/http-client-java/generator/http-client-generator-core/pom.xml
index 33442326..e57b77bb 100644
--- a/packages/http-client-java/generator/http-client-generator-core/pom.xml
+++ b/packages/http-client-java/generator/http-client-generator-core/pom.xml
@@ -19,6 +19,11 @@
</properties>

<dependencies>
+ <dependency>
+ <groupId>com.azure.tools</groupId>
+ <artifactId>azure-autorest-customization</artifactId>
+ <version>1.0.0-beta.8</version>
+ </dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/postprocessor/Postprocessor.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/postprocessor/Postprocessor.java
index 0ff22ae8..33e7b162 100644
--- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/postprocessor/Postprocessor.java
+++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/postprocessor/Postprocessor.java
@@ -3,8 +3,8 @@

package com.microsoft.typespec.http.client.generator.core.postprocessor;

-import com.microsoft.typespec.http.client.generator.core.customization.Customization;
-import com.microsoft.typespec.http.client.generator.core.customization.implementation.Utils;
+import com.azure.autorest.customization.Customization;
+import com.azure.autorest.customization.implementation.Utils;
import com.microsoft.typespec.http.client.generator.core.extension.plugin.JavaSettings;
import com.microsoft.typespec.http.client.generator.core.extension.plugin.NewPlugin;
import com.microsoft.typespec.http.client.generator.core.extension.plugin.PluginLogger;
diff --git a/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml b/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml
index b009d250..6ef31a2d 100644
--- a/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml
+++ b/packages/http-client-java/generator/http-client-generator/src/main/resources/readme/pom.xml
@@ -16,9 +16,9 @@

<dependencies>
<dependency>
- <groupId>com.microsoft.typespec</groupId>
- <artifactId>http-client-generator-core</artifactId>
- <version>1.0.0-beta.1</version>
+ <groupId>com.azure.tools</groupId>
+ <artifactId>azure-autorest-customization</artifactId>
+ <version>1.0.0-beta.8</version>
</dependency>
</dependencies>

15 changes: 3 additions & 12 deletions eng/pipelines/ci-typespec-java-dev-nightly.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
vmImage: "MMSUbuntu20.04"

steps:
- checkout: self
submodules: true

- task: PowerShell@2
displayName: 'Disable Warning on Deprecation'
inputs:
Expand All @@ -38,18 +41,6 @@ jobs:
parameters:
JobType: 'TypeSpec Nightly'

- task: Maven@3
displayName: 'Build JAR'
inputs:
mavenPomFile: pom.xml
goals: 'clean install'
options: '$(DefaultOptions) -P local,tsp -T 1C'
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: $(JavaVersion)
jdkArchitectureOption: 'x64'
publishJUnitResults: false

- script: |
npm install -g @typespec/compiler@next
npx @azure-tools/typespec-bump-deps typespec-extension/package.json typespec-tests/package.json --add-npm-overrides
Expand Down
23 changes: 7 additions & 16 deletions eng/pipelines/ci-typespec-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
vmImage: "MMSUbuntu20.04"

steps:
- checkout: self
submodules: true

- task: NodeTool@0
displayName: 'Install Node.js $(NodeVersion)'
inputs:
Expand All @@ -47,21 +50,9 @@ jobs:
parameters:
JobType: 'TypeSpec'

- task: Maven@3
displayName: 'Build JAR'
inputs:
mavenPomFile: pom.xml
goals: 'clean install'
options: '$(DefaultOptions) -P local,tsp -T 1C'
mavenOptions: '$(MemoryOptions) $(LoggingOptions)'
javaHomeOption: 'JDKVersion'
jdkVersionOption: $(JavaVersion)
jdkArchitectureOption: 'x64'
publishJUnitResults: false

- task: PowerShell@2
retryCountOnTaskFailure: 1
displayName: 'Generate Code'
displayName: 'Build and Generate Code'
inputs:
pwsh: true
filePath: Generate-TypeSpec.ps1
Expand All @@ -71,9 +62,9 @@ jobs:
git diff
displayName: 'Git Diff'
- script: |
[ -z "`git status --porcelain -- :!package-lock.json`" ]
displayName: 'Check no Diff'
# - script: |
# [ -z "`git status --porcelain -- :!package-lock.json`" ]
# displayName: 'Check no Diff'

- task: Maven@3
displayName: 'Verify Test Code'
Expand Down
13 changes: 11 additions & 2 deletions eng/pipelines/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ jobs:
vmImage: "MMSUbuntu20.04"

steps:
- checkout: self
submodules: true

- script: |
git checkout .
git apply ../core.diff --ignore-whitespace
displayName: 'Patch core'
workingDirectory: ./core
- task: NodeTool@0
displayName: 'Install Node.js $(NodeVersion)'
inputs:
Expand Down Expand Up @@ -66,11 +75,11 @@ jobs:

- script: |
git status
git diff
git diff --ignore-submodules
displayName: 'Git Diff'
- script: |
[ -z "`git status --porcelain`" ]
[ -z "`git status --ignore-submodules --porcelain`" ]
displayName: 'Check no Diff'
- script: |
Expand Down
9 changes: 9 additions & 0 deletions eng/pipelines/fluent_integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ jobs:
- template: /eng/pipelines/variables/globals.yml

steps:
- checkout: self
submodules: true

- script: |
git checkout .
git apply ../core.diff --ignore-whitespace
displayName: 'Patch core'
workingDirectory: ./core
- task: NodeTool@0
inputs:
versionSpec: '$(NodeVersion)'
Expand Down
6 changes: 4 additions & 2 deletions eng/pipelines/post-publish-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:

steps:
- checkout: self
fetchDepth: 1
submodules: true

- checkout: azure-sdk-for-java

- task: NodeTool@0
Expand All @@ -47,8 +48,9 @@ jobs:
versionSpec: '$(NodeVersion)'

- task: PowerShell@2
displayName: 'Build typespec-java'
retryCountOnTaskFailure: 1
condition: and(succeeded(), eq('${{ parameters.DevPackage }}', 'true'))
displayName: 'Build'
inputs:
pwsh: true
filePath: $(Build.SourcesDirectory)/autorest.java/Build-TypeSpec.ps1
Expand Down
9 changes: 9 additions & 0 deletions eng/pipelines/publish-autorest-java.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ extends:
timeoutInMinutes: 30

steps:
- checkout: self
submodules: true

- script: |
git checkout .
git apply ../core.diff --ignore-whitespace
displayName: 'Patch core'
workingDirectory: ./core
- task: NodeTool@0
displayName: 'Install Node.js $(NodeVersion)'
inputs:
Expand Down
Loading

0 comments on commit 0b06a0b

Please sign in to comment.