meetup / rules_openapi

🍃 bazel rules for generating code from openapi specifications
MIT License
52 stars 25 forks source link

feat: added support for building on Windows #42

Open sakanaou opened 3 years ago

sakanaou commented 3 years ago

When I tried to use this package for my build setup at https://github.com/sakanaou/openapi-first I noticed it does not execute correctly on Windows:

C:\prj\openapi-first>bazel build --verbose_failures //backend-v1
INFO: Analyzed target //backend-v1:backend-v1 (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: C:/prj/openapi-first/backend-v1/BUILD.bazel:4:12: error executing shell command: 'C:/WINDOWS/system32/bash.exe -c mkdir -p backend-v1/openapi_backend_v1_gen && external/local_jdk/bin/java.exe -cp external/io_bazel_rules_openapi_org_openapitools_openapi_generator_cli/openapi-gene...' failed (Exit 1): bash.exe failed: error executing command
  cd C:/users/daing/_bazel_daing/j3rcz5bc/execroot/__main__
C:/WINDOWS/system32/bash.exe -c mkdir -p backend-v1/openapi_backend_v1_gen && external/local_jdk/bin/java.exe -cp external/io_bazel_rules_openapi_org_openapitools_openapi_generator_cli/openapi-generator-cli-4.3.1.jar: org.openapitools.codegen.OpenAPIGenerator generate -i backend-v1/api.yaml -g spring -o backend-v1/openapi_backend_v1_gen -D "" --additional-properties "delegatePattern=true" --type-mappings "" --api-package de.cegeka.jax.backend.v1.api --invoker-package de.cegeka.jax.backend.v1.server --model-package de.cegeka.jax.backend.v1.model 2>/dev/null && find backend-v1/openapi_backend_v1_gen -exec touch -t 198001010000 {} \; && external/local_jdk/bin/jar cMf bazel-out/x64_windows-fastbuild/bin/backend-v1/openapi_backend_v1_gen_codegen.srcjar -C backend-v1/openapi_backend_v1_gen .
Execution platform: @local_config_platform//:host
Target //backend-v1:backend-v1 failed to build
INFO: Elapsed time: 0.865s, Critical Path: 0.52s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

This is due to the fact, that the classpath separator is different there and the jar command must be called with the appropiate extension. I adjusted the relevant portions so the build works fine now.

chenrui333 commented 3 years ago

I just added windows-latest to the CI, will merge this PR after the CI run. Thanks for your improvement, @sakanaou!