2018年4月16日 星期一

[java][gradle] gradle常用指令





常用指令集

Init Project

  • gradle init
  • gradle init --type java-library

Build Project

  • gradle clean build

Show all supported gradle tasks

  • gradle tasks

Static Code Analysis (YOU MUST DO THIS)

Unit Test

  • gradle test
  • gradle -x test // skip test
    測試完可於build/reports/資料夾觀察測試結果

Integration Test

  • gradle integrationTest
  • gradle -x integrationTest // skip integrationTest
    測試完可於build/reports/資料夾觀察測試結果

Liquibase

  • gradle update // 執行DB Migration到最新版本
  • gradle validate // Checks the changelog for errors
  • gradle dropAll // Drops all database objects owned by the user
  • gradle rollback // Rolls back the database to the state it was in when the tag was applied.
NOTE
  • SQL檔內容必須要用Linux的換行字元:\n,避免Liquibase讀不到
  • 若liquibase需要透過spring framework來整合啟動,則必須在spring beans的設定檔(ex: configs.xml)中加入以下XML程式碼片段: (可參考根專案底下src/main/resources/liquibase-springintegration.xml的設定)
  • <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
    <property name="dataSource" ref="dataSource" />
    <property name="changeLog" value="classpath:db/migration/changelog-master.yml" />
    <property name="dropFirst" value="true" />
    </bean>
  • SQL檔請放置於src/main/resources/db/migration資料夾中
  • Liquibase changelog檔案(src/main/resources/db/changelog-master.xml)必須進行以下宣告:
    databaseChangeLog:
    - preConditions:
    - runningAs:
    dbms: postgresql
    username: postgres
    - changeSet:
    id: 01_00_c_global_schema_20151005
    author: steed
    changes:
    - sqlFile:
    path: ../migrate_sql/01_00_c_global_schema_20151005.sql
    relativeToChangelogFile: true
    rollback:
    - sqlFile:
    path: ../migrate_sql/01_00_c_global_schema_20151005_rollback.sql
    relativeToChangelogFile: true

Packaging Jar/War

  • gradle jar
  • gradle war

Watch Project Layout

  • gradle projects

Show Project dependencies


  • gradle dependencies

沒有留言:

張貼留言