I found an unfamiliar file .idea/jarRepositories.xml
, when I updated Android Studio 3.5.3
to 4.0.1
on Mac. The content is as follows:
<?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>
There is already a question on it, and VonC answered that it can be added to .gitignore
.
I was wondering if I should add it in .gitignore
and shouldn't commit it to git. How can I decide to add it to .gitignore
?
The popular repository gitignore of github has Android.gitignore
, but it has no .idea/jarRepositories.xml
at the time of writing this question.
On the other hand, Global/JetBrains.gitignore
has the following comments.
# 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
As you can see, it has .idea/jarRepositories.xml
and the line is commented out. It also has the following notes:
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.
In Android Studio 4.0.x
, is it possible to use Gradle without auto-import?
In the above Global/JetBrains.gitignore
, the line # .idea/jarRepositories.xml
has been added by davidkron's pull request, and he commented as follows:
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
As his comment, Android Studio 4.0.1
has Remote Jar Repositories
settings, as you can see in the following screen shot.
I checked the release notes of Android Studio 4.0.0
, and found a section as follows:
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
I'm not sure but was wondering if I should add .idea/jarRepositories.xml
in .gitignore
and shouldn't commit it to git. How can I decide to add it or not? I really appreciate it if someone could clarify the criteria.
In the source code of Android Studio 4.0.0
, I found source files, which define the file name 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> {
// ...
}
I also found their origins in the repository of JetBrain's IntelliJ IDEA Community Edition.
Jps
stands for JetBrains Project System, according to a document:
The project model in External Build process is provided by JPS (JetBrains Project System).
JPS's previous repository describes itself as:
Gant based build framework + dsl, with declarative project structure definition and automatic IntelliJ IDEA projects build
The workspace. xml file stores personal settings such as placement and positions of your windows, your VCS and History settings, and other data pertaining to the development environment. It also contains a list of changed files and other sensitive information. These files should not be present on a production system.
misc.xml contains local environment specific information, for example project interpreter name, like this <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (myvirtenvname)" project-jdk-type="Python SDK" />
You shouldn't ignore the idea folder. you're supposed to commit almost all of it to the repo.
According to that page, you should check in all files in the . idea directory except: workspace. xml.
The file .idea/jarRepositories.xml
should be added to .gitignore
. It is auto-generated and has only redundant information about remote jar repositories.
Our Android projects define those repositories in the project-level build.gradle
such as:
allprojects {
repositories {
google()
jcenter()
}
}
The second reference wrote the following introduction at the top of its webpage:
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]
Also, Add Library Dependencies dialog in Android Studio 4.0.1
has an instruction like this:
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)
You can find it with the following steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With