version: 0.2
env:
  variables:
    JAVA_HOME: "/usr/lib/jvm/java-21-amazon-corretto/"
phases:
  install:
    commands:
    - apt-get update; apt-get install -y java-21-amazon-corretto-jdk
    - update-alternatives --auto javac
    - update-alternatives --auto java
    - pip install awscli==1.19.34 --upgrade --user

  pre_build:
    commands:
    - DOC_PATH='s3://aws-java-sdk-javadoc/java/api'

  build:
    commands:
    - python ./scripts/doc_crosslinks/generate_cross_link_data.py --apiDefinitionsBasePath ./services/ --apiDefinitionsRelativeFilePath src/main/resources/codegen-resources/service-2.json  --templateFilePath ./scripts/doc_crosslinks/crosslink_redirect.html --outputFilePath ./scripts/crosslink_redirect.html
    - mvn install -P quick -T1C
    - mvn clean install javadoc:aggregate -B -Ppublic-javadoc -Dcheckstyle.skip -Dspotbugs.skip -DskipTests -Ddoclint=none -pl '!:protocol-tests,!:protocol-tests-core,!:codegen-generated-classes-test,!:sdk-benchmarks,!:s3-benchmarks,!:module-path-tests,!:test-utils,!:http-client-tests,!:tests-coverage-reporting,!:sdk-native-image-test,!:ruleset-testing-core,!:old-client-version-compatibility-test'
    - RELEASE_VERSION=`mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec`
    -
    - aws s3 sync target/site/apidocs/ $DOC_PATH/$RELEASE_VERSION/ --acl="public-read"
    - aws s3 cp ./scripts/crosslink_redirect.html $DOC_PATH/$RELEASE_VERSION/ --acl="public-read"
    - aws s3 sync $DOC_PATH/$RELEASE_VERSION/ $DOC_PATH/latest/ --acl=public-read --delete
    - jar cf aws-java-sdk-v2-docs.jar -C target/site/apidocs .
    - aws s3 cp aws-java-sdk-v2-docs.jar $DOC_PATH/ --acl="public-read"