Android Studio項目模板

Android Studio在新建項目時會根據模板生成初始文件,我們可以修改文件模板。

項目模板

模板所在目錄:Android Studio\plugins\android\lib\templates
下面我將修改兩個文件,分別是build.gradle.ftl和project_ignore。

build.gradle.ftl

模板所在目錄:templates\gradle-projects\NewAndroidProject\root
對應build.gradle(Project)文件,利用阿里雲鏡像解決build速度慢的問題。
模板如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    <#if includeKotlinSupport!false>ext.kotlin_version = '${kotlinVersion}'</#if>
    repositories {
        <#-- google()
        jcenter() -->
        
        // maven庫
        def cn = "http://maven.aliyun.com/nexus/content/groups/public/"
        def abroad = "http://central.maven.org/maven2/"
        // 先從url中下載jar若沒有找到,則在artifactUrls中尋找
        maven {
            url cn
            artifactUrls abroad
        }
        maven { url "http://maven.aliyun.com/nexus/content/repositories/jcenter"}
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:${gradlePluginVersion}'
        <#if includeKotlinSupport!false>classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"</#if>

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        <#-- google()
        jcenter() -->

        // maven庫
        def cn = "http://maven.aliyun.com/nexus/content/groups/public/"
        def abroad = "http://central.maven.org/maven2/"
        // 先從url中下載jar若沒有找到,則在artifactUrls中尋找
        maven {
            url cn
            artifactUrls abroad
        }
        maven { url "http://maven.aliyun.com/nexus/content/repositories/jcenter"}
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

project_ignore

文件目錄:templates\gradle-projects\NewAndroidProject\root
對應.gitignore文件,表示Git版本管理忽略提交規則。
模板如下:

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Android Studio
*.iml
.idea
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/
.navigation
captures/
output.json 

#NDK
obj/
.externalNativeBuild
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章