Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement]: Run Maven@4 task in detached mode #20044

Open
tomaytotomato opened this issue Jun 20, 2024 · 0 comments
Open

[enhancement]: Run Maven@4 task in detached mode #20044

tomaytotomato opened this issue Jun 20, 2024 · 0 comments

Comments

@tomaytotomato
Copy link

tomaytotomato commented Jun 20, 2024

Task name

No response

Describe your feature request here

It would be nice to have an option to detach a maven process, so that we can start a webservice and have it running as a background task.

Usecases:

  • Integration tests
  • Generating OpenAPI.yml files from running webservice

In this example, I am currently using a script to start the webservice and then run the OpenApi Generate task afterwards

  - stage: PublishOpenAPI
#    dependsOn: Build
    displayName: Publish OpenAPI Specification
    jobs:
      - job: publishOpenAPI
        displayName: Publish OpenAPI Spec
        steps:
          - task: JavaToolInstaller@0
            inputs:
              versionSpec: '21'
              jdkArchitectureOption: 'x64'
              jdkSourceOption: 'PreInstalled' # Use 'PreInstalled' or 'AzureStorage' based on availability
          - task: Cache@2
            inputs:
              key: 'maven | "$(Agent.OS)" | **/pom.xml'
              restoreKeys: |
                maven | "$(Agent.OS)"
                maven
              path: $(MAVEN_CACHE_FOLDER)
          - script: |
              echo "Starting Spring Boot application in the background..."
              mvn -f server/pom.xml spring-boot:run &
              SPRING_PID=$!
              echo "Waiting for the Spring Boot application to start..."
              sleep 10
          - task: Maven@4
            displayName: Generate OpenApi.yml from service
            inputs:
              mavenPomFile: 'server/pom.xml'
              mavenOptions: '-Xmx3072m $(MAVEN_OPTS)'
              jdkVersionOption: $(JAVA_VERSION)
              javaHomeOption: 'JDKVersion'
              goals: 'springdoc-openapi:generate'
              options: '-B -e'
          - publish: server/target/openapi.yml
            artifact: OpenAPI

Maybe we could have an option in inputs like

detach: true

This would effectively just do the following

mvn ${mvnOptions} ${mvnGoal} &

The & is Unix specific but for Windows it would do a similar thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants