gpt4 book ai didi

android - 我如何决定在 .gitignore 中添加 .idea/jarRepositories.xml

转载 作者:行者123 更新时间:2023-12-03 16:53:10 25 4
gpt4 key购买 nike

我发现了一个不熟悉的文件 .idea/jarRepositories.xml ,当我更新 Android Studio 3.5.34.0.1在 Mac 上。内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>
已经有一个 question就可以了, VonC answered可以添加到 .gitignore .
我想知道是否应该将其添加到 .gitignore并且不应该将其提交给 git。我如何决定将其添加到 .gitignore ?
JetBrains.gitignore
流行的存储库 gitignoregithub Android.gitignore ,但它没有 .idea/jarRepositories.xml在写这个问题的时候。
另一方面, Global/JetBrains.gitignore 有以下评论。
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
如您所见,它有 .idea/jarRepositories.xml并且该行被注释掉了。它还有以下注释:

Gradle and Maven with auto-import

When using Gradle or Maven with auto-import, you should exclude module files,since they will be recreated, and may cause churn. Uncomment if usingauto-import.


在 Android Studio 4.0.x ,是否可以在没有自动导入的情况下使用 Gradle?
远程 Jar 存储库
在上面 Global/JetBrains.gitignore , 行 # .idea/jarRepositories.xml已由 davidkron 的 pull request 添加, 而他 commented如下:

Since IntelliJ 2019.3 this file appeared automatically in our git changes. It seems these are just cached information about remote repositories that are defined in Maven/Gradle.

Reasons for making this change:

In a Maven/Gradle build, automatically generated files should should not be commited.

Links to documentation supporting these rule changes:

I haven't found a documentation or article about this file, but I'm basing my assumption on the following steps:

  • in IntelliJ the "Remote Jar Repositories" can be managed in the Settings menu
  • I deleted every entry in the list -> file disappeared
  • I re-imported the Maven/Gradle project again
  • the file appeared again with the same entries present as before

正如他的评论,Android Studio 4.0.1Remote Jar Repositories设置,如您在以下屏幕截图中所见。
enter image description here
我查看了 Android Studio 的发行说明 4.0.0 ,并找到 a section如下:

IntelliJ IDEA 2019.3.3

The core Android Studio IDE has been updated with improvements from IntelliJ IDEA through the 2019.3.3 release.

To learn more about the improvements from other IntelliJ versions that are included cumulatively with version 2019.3.3, see the following pages:

  • IntelliJ IDEA 2019.3
  • IntelliJ IDEA 2019.3.3

我不确定,但想知道是否应该添加 .idea/jarRepositories.xml.gitignore并且不应该将其提交给 git。我如何决定是否添加它?如果有人能澄清标准,我真的很感激。
更新:
Android Studio 源码中 4.0.0 ,我找到了源文件,其中定义了文件名 jarRepositories.xml :
JpsRemoteRepositoriesConfigurationSerializer.java
public JpsRemoteRepositoriesConfigurationSerializer() {
super("jarRepositories.xml", "RemoteRepositoriesConfiguration");
}
RemoteRepositoriesConfiguration.java
@State(name = "RemoteRepositoriesConfiguration", storages = @Storage("jarRepositories.xml"))
public class RemoteRepositoriesConfiguration implements PersistentStateComponent<RemoteRepositoriesConfiguration.State> {
// ...
}
我还在 JetBrain 的 IntelliJ IDEA 社区版的存储库中找到了它们的起源。
  • JpsRemoteRepositoriesConfigurationSerializer.java
  • RemoteRepositoriesConfiguration.java
  • Jps代表 JetBrains 项目系统 , 根据 a document :

    The project model in External Build process is provided by JPS (JetBrains Project System).


    JPS's previous repository将自己描述为:

    Gant based build framework + dsl, with declarative project structure definition and automatic IntelliJ IDEA projects build

    最佳答案

    文件.idea/jarRepositories.xml应添加到 .gitignore .它是自动生成的,只有关于 remote jar repositories 的冗余信息.
    我们的 Android 项目在项目级别 build.gradle 中定义了这些存储库。如:

    allprojects {
    repositories {
    google()
    jcenter()
    }
    }
  • https://developer.android.com/studio/build#top-level
  • https://developer.android.com/studio/build/dependencies.html#remote-repositories
  • https://docs.gradle.org/current/userguide/dependency_management.html#declaring-repositories

  • 第二个引用在其网页顶部写了以下介绍:

    Add build dependencies

    The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies....This page describes how to use dependencies with your Android project,...but remember that your Android project must use only the dependency configurations defined on this page. [emphasis added]


    另外, 添加库依赖 Android Studio 中的对话框 4.0.1有这样的指令:

    Step 1.

    Use the form below to find the library to add. This form uses the repositories specified in the project's build files (Google, JCenter, Android Repository, Google Repository)


    您可以通过以下步骤找到它:
  • 选择 文件 > 项目结构... 在 Android Studio 的菜单中。
  • 选择 依赖 的左侧菜单中项目结构对话。
  • 选择 应用 模块 柱子。
  • 选择 + 声明的依赖关系 柱子。
  • 选择 1 库依赖 在弹出菜单中。
  • 关于android - 我如何决定在 .gitignore 中添加 .idea/jarRepositories.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63342780/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com