DEV Community

Edgar Rios Navarro
Edgar Rios Navarro

Posted on

1 1

Compilar una aplicación Java 7 en un pipeline

Puede que no sea el caso para la mayoría de los proyectos, pero si tu aplicación depende de un S.O. de 32 bits; es imposible actualizar la versión de Java.

Ello no impide automatizar la construcción, mediante un Pipeline de Azure.


Los aspectos a tener en cuenta:

  1. Proveer las herramientas necesarias
    • JDK 1.7
    • Ant 1.19
  2. Instalar y configurar previo a la compilación

Lo recomendable es no agregar estos binarios en el propio source code. Por esa razón (y facilidad al usar GIT) se creo un repositorio que contiene los archivos necesarios.

https://gitlab.com/edgar.gs/posunificado-build-java7.git

El archivo azure-pipeline.yml luce de esta forma:

# Ant
# Build your Java projects and run tests with Apache Ant.
# Add steps that save build artifacts and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

trigger:
- master

pool:
  vmImage: windows-latest

steps:
- script: |
    git clone https://gitlab.com/edgar.gs/posunificado-build-java7.git
- task: CopyFiles@2
  inputs:
    SourceFolder: 'posunificado-build-java7/build/jre7/lib/'
    Contents: '*.jar'
    TargetFolder: 'C:\jre7\lib'    
- task: JavaToolInstaller@0
  inputs:
    versionSpec: '7'
    jdkArchitectureOption: 'x86'
    jdkSourceOption: LocalStorage
    jdkFile: 'posunificado-build-java7/build/jdk1.7.0_65.7z'
    jdkDestinationDirectory: '$(agent.toolsDirectory)/jdk7'
    cleanDestinationDirectory: false
- task: ExtractFiles@1
  inputs:
    archiveFilePatterns: 'posunificado-build-java7\build\apache-ant-1.9.16-bin.zip'
    #destinationFolder:
    cleanDestinationFolder: false
    overwriteExistingFiles: false    
- task: Ant@1
  inputs:
    antHomeDirectory: 'apache-ant-1.9.16'
    workingDirectory: ''
    buildFile: 'fps-app-ws-posunificado/build-azure.xml'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.7'
    jdkArchitectureOption: 'x86'
    publishJUnitResults: false
    #testResultsFiles: '**/TEST-*.xml'
- task: CopyFiles@2
  inputs:
    contents: 'fps-app-ws-posunificado/deploy/**'
    targetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: MyBuildOutputs
Enter fullscreen mode Exit fullscreen mode

Se puede observar la ejecución en el siguiente video:


Documentación

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/tool/java-tool-installer?view=azure-devops
https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/ant?view=azure-devops

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay