[英]What is the difference between Files uploaded to bintray.com?
I uploaded my lib to bintray.com by the tutorial , and now there in tab "Files" exist the list of files. 我通过教程将我的lib上传到bintray.com,现在在“文件”选项卡中存在文件列表。
1) Which one can I add directly to app/libs
folder 1)我可以直接添加到app/libs
文件夹中
2) What is the difference between Files uploaded to bintray.com? 2)上传到bintray.com的文件有什么区别?
3) How to find the files in MyProject without make command gradlew bintrayUpload
? 3)如何在没有make命令的情况下在MyProject中查找文件gradlew bintrayUpload
?
*-javadoc.jar
*-javadoc.jar.asc
*-sources.jar
*-sources.jar.asc
*.aar
*.aar.asc
*.pom
*.pom.asc
Let's take the questions one at a time: 我们一次一个地提出问题:
1) Which one can I add directly to app/libs folder 1)我可以直接添加到app / libs文件夹中
That would be *.aar
file. 那将是*.aar
文件。 The .aar
file contains your compiled code & other resources you defined in your library (for instance XML files). .aar
文件包含您在库中定义的已编译代码和其他资源(例如XML文件)。
AAR stands for Android Archive . AAR代表Android档案 。 It's Android's new binary format for libraries, an equivalent of a *.jar
from the Java world. 它是Android的新二进制格式库,相当于Java世界的*.jar
。 (see this ) (见这个 )
This contains just the compiled code though. 这只包含已编译的代码。 No javadoc, no sources. 没有javadoc,没有消息来源。
2) What is the difference between Files uploaded to bintray.com? 2)上传到bintray.com的文件有什么区别?
Let's take each file one by one: 让我们逐个采取每个文件:
<library name>.pom
1. <library name>.pom
This is a XML file that stores metadata about your library. 这是一个存储有关库的元数据的XML文件。
Typically, it stores the following: 通常,它存储以下内容:
mylibrary
) 你的工件的名称(例如mylibrary
) com.myname.mycompany
) 发布工件的组(即组织)(例如com.myname.mycompany
) packaging
- defines what file type the binary is (it's aar
for Android library, war
for certain Java libraries, etc) packaging
-定义二进制是什么文件类型(这是aar
的Android库, war
对于某些Java库等) POM files are just the standard metadata file for Maven repositories. POM文件只是Maven存储库的标准元数据文件。 There are other types of repositories, such as Ivy repositories , which use other XML formats for their metadata: Ivy.xml files . 还有其他类型的存储库,例如Ivy存储库 ,它们使用其他XML格式作为其元数据: Ivy.xml文件 。
Since your repository is a Maven repository, the metadata is stored in a -pom.xml
file. 由于您的存储库是Maven存储库,因此元数据存储在-pom.xml
文件中。
<library name>.aar
2. <library name>.aar
As explained above, this stores the compiled Java/Kotkin code. 如上所述,这存储了编译的Java / Kotkin代码。 Also containes various Android resources, such as Strings, Drawables, Layout files, themes, stylables, etc. 还包含各种Android资源,如字符串,Drawables,布局文件,主题,样式等。
See here for details. 详情请见此处 。
library name>-javadoc.jar
3. library name>-javadoc.jar
Stores HTML documentation files generated from your code using the javadoc
tool (or dokka
if you used Kotlin). 使用javadoc
工具存储从您的代码生成的HTML文档文件(如果您使用Kotlin,则dokka
)。
This is just an archive, not an executable. 这只是一个存档,而不是可执行文件。 You can just open it with Total Commander or WinRar and check its contents. 您可以使用Total Commander或WinRar打开它并检查其内容。
library name>-sources.jar
4. library name>-sources.jar
Contains the sources for your library. 包含库的源代码。 This again is just an archive, not an executable. 这又是一个存档,而不是可执行文件。
It contains your actual *.java
or *.kotlin
files, complete with comments. 它包含您的实际*.java
或*.kotlin
文件,以及注释。 Having this file allows clients of your library to properly see your code, step over it line by line, and better understand what your code does. 拥有此文件允许您的库的客户端正确地查看您的代码,逐行检查它,并更好地了解您的代码所做的事情。
This is also the file that gets read by the IDE when someone opens the documentation for a class of a your library, to show you the documentation for that class within the IDE. 当有人打开库的类文档时,这也是IDE读取的文件,以便在IDE中显示该类的文档。 Without this file they would have to use the online documentation or to look at the files from <library-name>-javadoc.jar
. 如果没有此文件,他们将不得不使用在线文档或查看<library-name>-javadoc.jar
中的文件。
Be careful if you library is not open source & has proprietary code: Do not also publish the sources! 如果您的库不是开源的并且拥有专有代码,请小心: 不要发布源代码!
<library-name>.<extension>.asc
5. <library-name>.<extension>.asc
It's a file generated by Bintray to guarantee that you're the one who uploaded the file. 这是Bintray生成的文件,用于保证您是上传文件的人。 This is why all your files have also an *.asc
corespondent. 这就是为什么你的所有文件都有一个*.asc
。
Think of it as a digital signature for each of your files. 可以将其视为每个文件的数字签名。 It's actually created by the steps in "Part 3" of the tutorial you linked. 它实际上是由您链接的教程的“第3部分”中的步骤创建的。 If you skip Part 3, then no ` .asc files will be generated. 如果跳过第3部分,则不会生成` .asc文件。
3) How to find the files in MyProject without make command gradlew bintrayUpload? 3)如何在没有make命令的情况下在MyProject中查找文件gradlew bintrayUpload?
*.pom
I assume you're using the Bintray Gradle Plugin, since you mentioned the bintrayUpload
task. 我假设您正在使用Bintray Gradle插件,因为您提到了bintrayUpload
任务。
Somewhere in your gradle files, you should have something like this: 在你的gradle文件中的某个地方,你应该有这样的东西:
publishing {
publications {
MyPublicationName(MavenPublication) {
...
}
}
}
This defines a publication object called MyPublicationName
. 这定义了一个名为MyPublicationName
的发布对象。
Thanks to the Bintray Gradle plugin, then you should have the following task available: generatePomFileForMyPublicationNamePublication
. 感谢Bintray Gradle插件,您应该可以使用以下任务: generatePomFileForMyPublicationNamePublication
。
So to generate the *.pom
you have to run: 因此要生成*.pom
您必须运行:
./gradle generatePomFileForMyPublicationNamePublication
Replace MyPublicationName
with the name you defined for your publication. 将MyPublicationName
替换为您为发布定义的名称。
*.aar
./gradle :moduleName:assembleRelease
Just replace moduleName
with the name of your library module. 只需将moduleName
替换为库模块的名称即可。
*-sources.jar
You need to define a task which archives your source files under a jar. 您需要定义一个将源文件归档到jar下的任务。 Mine looks the following way: 我看起来如下:
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
Then you can just call: 然后你可以打电话:
./gradle :moduleName:sourcesJar
As before, replace moduleName
with the name of your library module. 和以前一样,将moduleName
替换为库模块的名称。
*-javadoc.jar
You typically need to define 2 tasks for this: 您通常需要为此定义2个任务:
javadoc
tool over your classes, to generate the HTML documentation files from the documentation present in your code. 一个任务是在类上调用javadoc
工具,从代码中的文档生成HTML文档文件。 .jar
file (like we did for the sources.jar file) 第二个任务,它接收HTML文件并将它们捆绑在.jar
文件中(就像我们为sources.jar文件所做的那样) My setup looks in the following way: 我的设置以下列方式查看:
//generates HTML files from the documentation present in your source files
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
failOnError false
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
//takes the generated html documentation files, and archives them in a jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
Then invoke: 然后调用:
./gradle :moduleName:javadocJar
And you're set! 你就定了! Also, replace moduleName
with the name of your library module. 另外,将moduleName
替换为库模块的名称。
*.asc
These files are actually generated by Bintray after you upload your files. 上传文件后,这些文件实际上是由Bintray生成的。 There's no need to generate them locally. 没有必要在本地生成它们。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.