首页 > 解决方案 > 将属性传递给 ANT build.xml 文件

问题描述

我是 Stack Overflow 和 Azure 的新手。

我想要一个项目中的多个存储库。许多存储库将具有经常更改的源代码(repoX),一个具有很少更改的大型 jar 文件(repo2)。Repo2 将用于不同 repoX 中的 ANT 构建。在 Azure Pipeline for repoX 中,我想将 repo2 的路径传递给 build.xml 的类路径,但似乎找不到正确的语法。我熟悉 ANT,只需要语法。Azure 帮助显示了几种设置构建属性的方法,例如变量、环境等。

谢谢你的帮助。

标签: azureazure-devops

解决方案


非常感谢您的帮助。我能够将参数传递给我的构建文件。我无法让替换令牌任务工作(我认为它已被弃用),但由于 ANT 属性是不可变的,所以当我在 ANT 任务 OPTIONS 中设置我的类路径变量时,它会在构建文件中被拾取。这是我的管道:

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

resources:
  repositories:
  - repository: THE_JDK
    type: git
    name: FOLDER/THE_JDK

steps:
- checkout: self
- checkout: THE_JDK
- script: |
    echo $(Build.SourcesDirectory)
    ls $(Build.SourcesDirectory) *
    
- powershell: Write-Host "##vso[task.setvariable variable=jdk.home;]$(Build.SourcesDirectory)/THE_JDK"    

- task: Ant@1
  inputs:
    buildFile: 'trunk/TheApp/build/build.xml'
    options: -Djdk.home=$(jdk.home)
    targets: 'dist-trunk'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: true
    testResultsFiles: '**/TEST-*.xml'

推荐阅读