-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a dedicated SystemReader preventing JGit from using system config (…
- Loading branch information
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../allegro/tech/build/axion/release/infrastructure/git/SystemReaderWithoutSystemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package pl.allegro.tech.build.axion.release.infrastructure.git; | ||
|
||
import org.eclipse.jgit.lib.Config; | ||
import org.eclipse.jgit.storage.file.FileBasedConfig; | ||
import org.eclipse.jgit.util.FS; | ||
import org.eclipse.jgit.util.SystemReader; | ||
|
||
public class SystemReaderWithoutSystemConfig extends SystemReader | ||
{ | ||
private static final SystemReader DefaultSystemReader = SystemReader.getInstance(); | ||
|
||
@Override | ||
public String getenv(String variable) | ||
{ | ||
return DefaultSystemReader.getenv(variable); | ||
} | ||
|
||
@Override | ||
public String getHostname() | ||
{ | ||
return DefaultSystemReader.getHostname(); | ||
} | ||
|
||
@Override | ||
public String getProperty(String key) | ||
{ | ||
return DefaultSystemReader.getProperty(key); | ||
} | ||
|
||
@Override | ||
public long getCurrentTime() | ||
{ | ||
return DefaultSystemReader.getCurrentTime(); | ||
} | ||
|
||
@Override | ||
public int getTimezone(long when) | ||
{ | ||
return DefaultSystemReader.getTimezone(when); | ||
} | ||
|
||
@Override | ||
public FileBasedConfig openUserConfig(Config parent, FS fs) | ||
{ | ||
return DefaultSystemReader.openUserConfig(parent, fs); | ||
} | ||
|
||
@Override | ||
public FileBasedConfig openJGitConfig(Config parent, FS fs) { | ||
return DefaultSystemReader.openJGitConfig(parent, fs); | ||
} | ||
|
||
// Return an empty system configuration to prevent JGit from accessing it | ||
// This resolves issues with Gradle being unable to save configuration cache | ||
// Based on https://stackoverflow.com/a/59110721 | ||
@Override | ||
public FileBasedConfig openSystemConfig(Config parent, FS fs) | ||
{ | ||
return new FileBasedConfig(parent, null, fs) | ||
{ | ||
@Override | ||
public void load() | ||
{ | ||
} | ||
|
||
@Override | ||
public boolean isOutdated() | ||
{ | ||
return false; | ||
} | ||
}; | ||
} | ||
} |