常用gradle命令

1.build.gradle

ext {    profile = "dev"    tag=‘web‘    if (project.hasProperty(‘pro‘)) {

        temp = project.property(‘pro‘)        profile= temp.split(‘_‘)[0]        tag= temp.split(‘_‘)[1]    }    tag=tag+".gradle"

    proConfig= loadGroovyConfig()

    println profile+":"+ tag}

apply from :tag

def loadGroovyConfig() {    def configFile = file(‘config.groovy‘)    new ConfigSlurper(profile).parse(configFile.toURL()).toProperties()}

//gradle publishToMavenLocal -Ppro=test_external

2.web.gradle

apply plugin: ‘java‘apply plugin: ‘maven‘apply plugin: ‘war‘apply plugin: ‘jetty‘apply plugin: ‘idea‘

group = ‘com.infosky.icustoms‘version = ‘1.0‘

description = """"""

sourceCompatibility = 1.6targetCompatibility = 1.6

[compileJava, javadoc, compileTestJava]*.options*.encoding = ‘UTF-8‘

tasks.withType(JavaCompile) {    options.encoding = "UTF-8"}

configurations {    mycompile    myprovided    myonlycompile}sourceSets{    main{        if(project.profile==‘dev‘) {            compileClasspath += configurations.mycompile            compileClasspath += configurations.myprovided            compileClasspath += configurations.myonlycompile

            runtimeClasspath  += configurations.mycompile            runtimeClasspath  += configurations.myprovided        }else{            compileClasspath += configurations.mycompile            compileClasspath += configurations.myprovided            compileClasspath += configurations.myonlycompile

            runtimeClasspath  += configurations.mycompile        }    }}

repositories {    mavenLocal()    maven { url "http://172.21.129.57:8081/nexus/content/groups/public/" }    maven { url "http://repo.maven.apache.org/maven2" }}dependencies {

    mycompile group: ‘com.infosky.icustoms‘, name: ‘icustoms-sso-client‘, version:‘1.0‘, transitive: false

    myonlycompile group: ‘junit‘, name: ‘junit‘, version:‘3.8.1‘

    myprovided group: ‘ccsplib.infosky‘, name: ‘antlr-2.7.7‘, version:‘1.1.1‘

}

def loadGroovyConfig() {    def configFile = file(‘config.groovy‘)    new ConfigSlurper(profile).parse(configFile.toURL()).toProperties()}processResources {    from (‘src/main/java‘) {        include ‘**/*.sql‘        include ‘**/*.xml‘        include ‘**/*.ftl‘        include ‘**/*.properties‘    }

    println "begin replace profile!"    from(sourceSets.main.resources.srcDirs) {        filter(org.apache.tools.ant.filters.ReplaceTokens,                tokens: project.proConfig        )    }

    println ant.getProperties()//    ant.copy(file: ‘src/command.bar‘, tofile: ‘dist/command.bat‘, encoding: ‘sjis‘) {//        filterchain {//            replaceTokens {//                token(key: ‘jarPath‘, value=jar.archivePath.name)//            }//        }//    }

    println "end replace profile!"

}

idea {    module {        scopes.PROVIDED.plus += [configurations.myprovided,configurations.mycompile,configurations.myonlycompile]    }}

3.client.gradle
ext {    libName =  ‘icustoms-sso-client‘}apply plugin: ‘java‘apply plugin: ‘maven‘apply plugin: ‘maven-publish‘

group = ‘com.infosky.icustoms‘version = ‘1.0‘

description = """sso"""

sourceCompatibility = 1.6targetCompatibility = 1.6

tasks.withType(JavaCompile) {    options.encoding = "UTF-8"}

configurations {    mycompile    myprovided}sourceSets{    main{        resources {           // srcDirs=[ ‘SourceCode/resources‘]            exclude ‘**‘        }java{    include ‘sso/common/**/*.*‘    include ‘sso/client/**/*.*‘    include ‘sso/constants/*.*‘

    include ‘sso/ticket/**/*.*‘}

        if(project.profile==‘dev‘) {            compileClasspath += configurations.mycompile            compileClasspath += configurations.myprovided

            runtimeClasspath  += configurations.mycompile            runtimeClasspath  += configurations.myprovided        }else{            compileClasspath += configurations.mycompile            compileClasspath += configurations.myprovided

            runtimeClasspath  += configurations.mycompile        }    }}

repositories {        mavenLocal()     maven { url "http://172.21.129.57:8081/nexus/content/groups/public/" }     maven { url "http://repo.maven.apache.org/maven2" }}dependencies {    mycompile group: ‘ccsplib.infosky‘, name: ‘framework-core-bin‘, version:‘1.1.1‘

}

processResources {    from (‘src/main/java‘) {//        include ‘**/*.sql‘//        include ‘**/*.xml‘//        include ‘**/*.ftl‘//        include ‘**/*.properties‘//        include ‘**/*.vm‘        exclude ‘**/*.java‘    }

    println "begin replace profile!"    from(sourceSets.main.resources.srcDirs) {        filter(org.apache.tools.ant.filters.ReplaceTokens,                tokens: project.proConfig        )    }    println "end replace profile!"

}

jar {    baseName libName    from sourceSets.main.output

    include ‘sso/common/**/*.*‘    include ‘sso/client/**/*.*‘    include ‘sso/constants/*.*‘    include ‘sso/config/*.*‘    include ‘sso/utils/*.*‘    include ‘sso/holder/*.*‘    include ‘sso/user/**/*.*‘    include ‘sso/bean/**/*.*‘}

task sourceJar(type: Jar) {    from sourceSets.main.allJava

    include ‘sso/common/**/*.*‘    include ‘sso/client/**/*.*‘    include ‘sso/constants/*.*‘    include ‘sso/config/*.*‘    include ‘sso/utils/*.*‘    include ‘sso/holder/*.*‘    include ‘sso/user/**/*.*‘    include ‘sso/bean/**/*.*‘}

publishing {    publications {        mavenJava(MavenPublication) {            groupId group            artifactId libName            version version

            from components.java

            artifact sourceJar {                classifier "sources"            }        }    }}
时间: 2024-08-11 09:56:03

常用gradle命令的相关文章

史上最详细的Android Studio系列教程五--Gradle命令详解与导入第三方包

Android Studio + Gradle的组合用起来非常方便,很多第三方开源项目也早都迁移到了Studio,为此今天就来介绍下查看.编译并导入第三方开源项目的方法. Sublime + Terminal编译并查看源码 首先来给大家介绍一种简便并且个人最喜欢的一种办法.很多时候我们在GitHub上看到一个不错的开源项目,一般有两种需求,阅读源码和查看运行效果,如果是单纯的查看源码我更喜欢用一些轻量级编辑器,如vim,sublime等,vim不是很熟练,所以个人一种都习惯用sublime来查看

01. Shell基础和使用技巧(工具+常用bash命令加速操作)

Shell脚本介绍和常用工具 Shell脚本 Shell脚本:实际就是windows里的批处理脚本,多条可一次执行的Shell命令集合.Linux上的脚本可以用很多种语言实现,bash shell是比较简单的一种,更高阶的可以用其他脚本语言,比如Python. Shell脚本对系统的管理能力非常强大,甚至可以使用Shell结合php实现Web管理Linux系统功能:可以自己写一个Web页面(示例:基于Php),对系统进行管理,包括查看删除用户,配置网络,发送邮件,重启系统,一键备份,一键搭建服务

Linux服务器开发常用的命令以及遇到的问题

1. 什么是linux服务器load average? Load是用来度量服务器工作量的大小,即计算机cpu任务执行队列的长度,值越大,表明包括正在运行和待运行的进程数越多.参考资料:http://en.wikipedia.org/wiki/Load_average 2. 如何查看linux服务器负载 可以通过w,top,uptime,procinfo命令,也可以通过/proc/loadavg文件查看. 3. 服务器负载高怎么办? 服务器负载(load/load average)是根据进程队列的

常用 Git 命令清单

我每天使用 Git ,但是很多命令记不住. 一般来说,日常使用只要记住下图6个命令,就可以了.但是熟练使用,恐怕要记住60-100个命令. 下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一.新建代码库 # 在当前目录新建一个Git代码库 $ git init # 新建一个目录,将其初始化为Git代码库 $ git init [project-nam

Android 常用 adb 命令

在开发或者测试的过程中,我们可以通过 adb 来管理多台设备,其一般的格式为: adb [-e | -d | -s <设备序列号>] <子命令> 在配好环境变量的前提下,在命令窗口当中输入 adb help 或者直接输入 adb ,将会列出所有的选项说明及子命令.这里介绍一些里面常用的命令: 1 adb devices , 获取设备列表及设备状态 2 [xuxu:~]$ adb devices 3 List of devices attached 4 44c826a0 device

大数据基础之常用Linux命令

大数据实验环境一般为Linux,熟悉Linux操作非常有必要,总结常用Linux命令如下. 1.cd命令 进入文件夹: cd dirname 进入多级文件夹: cd /usr/local/Cellar 返回上层目录: cd ../ 返回上层的上层: cd ../../ 回到主文件夹 cd 2.ls命令 ls命令用于列出当前文件和目录,加上参数之后可以做更多的事情. 不带参数运行ls会列出文件和目录 ls 使用-l参数切换到长清单模式,会显示当前目录内容的长列表: ls -l 加上-lh参数显示文

Linux常用高频命令(自总结)

Linux常用高频命令(自总结) 在Linux环境下使用一些命令行和shell编程已经有很长时间了,一直想写一篇关于linux命令行和shell编程的文章,但被一些事情搁置下来了.今天抽出一些时间把Linux下常用的高频命令一个个亲自验证之后写了这篇文章.很多命令可能你用过,但是有时候可能记得有点模糊.这里将它系统的列举出来,希望能对自己和他人有些许帮助. 文件或目录的创建和删除 1)创建文件与目录 1)touch  file1  file2  file3 2) mkdir  -p  dir1/

常用 Git 命令清单 转

我每天使用 Git ,但是很多命令记不住. 一般来说,日常使用只要记住下图6个命令,就可以了.但是熟练使用,恐怕要记住60-100个命令. 下面是我整理的常用 Git 命令清单.几个专用名词的译名如下. Workspace:工作区 Index / Stage:暂存区 Repository:仓库区(或本地仓库) Remote:远程仓库 一.新建代码库 # 在当前目录新建一个Git代码库 $ git init # 新建一个目录,将其初始化为Git代码库 $ git init [project-nam

linux常用管理命令使用

1.Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示. 常用的命令:ls, cd, pwd, mkdir, cp, rm, mv, touch, cat, more, less, head, tail, du, wc ls: -A :列出当前目录全部的文件,连同隐藏档,但不包括 . 与 .. 这两个目录 -d :仅列出目录本身,而不是列出目录内的文件数据  -h :将文件容量以人类较易读的方式(例如 GB, KB 等等)列出来  -i :列出 inode 号码,inode