使用Android Studio中的Gradle创建src文件夹的zip文件

时间:2022-11-26 11:52:18

Having no knowledge of how gradle really works and how to use it well (I just copy paste snippets here and there), I was wondering if it was possible to ask gradle to generate a zip file containing the "src" folder of my Android app when I do generate the signed apk?

不知道gradle如何工作以及如何使用它(我只是在这里和那里复制粘贴片段),我想知道是否可以请求gradle生成包含我的Android应用程序的“src”文件夹的zip文件当我生成签名的apk?

It sounds strange, but I want some hard copy in addition to all the source control things included in Android Studio, just in case (as I don't manage well what would be the equivalent of source control for Photoshop and Illustrator...)

这听起来很奇怪,但除了Android Studio中包含的所有源代码控制内容之外,我还需要一些硬拷贝,以防万一(因为我管理得不好,相当于Photoshop和Illustrator的源代码控制......)

Thanks.

1 个解决方案

#1


I think you should look at Gradle Distribution Plugin

我想你应该看看Gradle Distribution Plugin

According to the documentation you might have to do the following things.

根据文档,您可能需要执行以下操作。

In your build.gradle add somewhere on top:

在你的build.gradle中添加一个顶部:

apply plugin: 'distribution'

You can then just run gradle distZip and accoriding to the docs:

然后,您可以运行gradle distZip并符合文档:

You can run “gradle distZip” to package the main distribution as a ZIP, or “gradle distTar” to create a TAR file. To build both types of archives just run gradle assembleDist. The files will be created at “$buildDir/distributions/$project.name-$project.version.«ext»”.

您可以运行“gradle distZip”将主发行版打包为ZIP,或者“gradle distTar”来创建TAR文件。要构建两种类型的存档,只需运行gradle assembleDist。这些文件将在“$ buildDir / distributions / $ project.name- $ project.version。«ext»”中创建。

Or you can play with some options, if you'd like to. To add data to be packed and to set output folder add:

或者,如果您愿意,可以选择一些选项。要添加要打包的数据并设置输出文件夹,请添加:

distributions {
    main {
        baseName = 'someName'
        contents {
            from { 'src/readme' }
        }
    }
}

apply plugin:'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://some/repo")
        }
    }
}

And to start deployment you should execute in the command line:

要开始部署,您应该在命令行中执行:

gradle distZip

Hope it helps

希望能帮助到你

#1


I think you should look at Gradle Distribution Plugin

我想你应该看看Gradle Distribution Plugin

According to the documentation you might have to do the following things.

根据文档,您可能需要执行以下操作。

In your build.gradle add somewhere on top:

在你的build.gradle中添加一个顶部:

apply plugin: 'distribution'

You can then just run gradle distZip and accoriding to the docs:

然后,您可以运行gradle distZip并符合文档:

You can run “gradle distZip” to package the main distribution as a ZIP, or “gradle distTar” to create a TAR file. To build both types of archives just run gradle assembleDist. The files will be created at “$buildDir/distributions/$project.name-$project.version.«ext»”.

您可以运行“gradle distZip”将主发行版打包为ZIP,或者“gradle distTar”来创建TAR文件。要构建两种类型的存档,只需运行gradle assembleDist。这些文件将在“$ buildDir / distributions / $ project.name- $ project.version。«ext»”中创建。

Or you can play with some options, if you'd like to. To add data to be packed and to set output folder add:

或者,如果您愿意,可以选择一些选项。要添加要打包的数据并设置输出文件夹,请添加:

distributions {
    main {
        baseName = 'someName'
        contents {
            from { 'src/readme' }
        }
    }
}

apply plugin:'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "file://some/repo")
        }
    }
}

And to start deployment you should execute in the command line:

要开始部署,您应该在命令行中执行:

gradle distZip

Hope it helps

希望能帮助到你