記錄下作的過程,這是一個簡單的Gradle項目,主要用來測試一些日誌的寫法,日誌的輸出等等。java
建立項目大概是下面這些步驟:git
建立一個目錄(test),並執行git init
置於git管理下。web
在目錄test下建立build.gradle
文件。spring
在build.gradle
中添加apply plugin: 'java'
,這會添加一些定製的java tasks。api
添加依賴的maven倉庫app
repositories { mavenLocal() maven{ url 'http://localhost:8081/artifactory/libs-release/'} }
添加依賴示例:eclipse
dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2' testCompile group: 'junit', name: 'junit', version: '4.+' }
定製項目,添加屬性:version = '1.0'
maven
配置發佈文件到本地目錄,學習
uploadArchives { repositories { flatDir { dirs 'repos' } } }
添加apply plugin: 'eclipse'
用來生成eclipse項目文件。測試
可使用命令gradle -q dependencies web:dependencies
查看項目的全部依賴信息。
能夠自定義項目屬性,
ext { slf4jVersion = '1.7.21' }
使用項目屬性"org.slf4j:slf4j-api:${slf4jVersion}"
能夠過濾項目的依賴信息gradle -q dependencies --configuration compile
,查看依賴能夠清晰的看到依賴的傳遞過程.
可使用exclude排除指定的依賴
compile ("org.slf4j:slf4j-log4j12:${slf4jVersion}"){ exclude module:"log4j" exclude module:"slf4j-api" }
終於把springframework構建完成了,命令:gradle build -x test -x javadoc --info
主要是學習下,大概是抄了下文檔。SLF4J使用手冊中文版