mirror of
https://github.com/ironfox-oss/IronFox.git
synced 2026-06-11 17:54:30 -04:00
fix: use perl script to localize maven
This commit is contained in:
38
scripts/localize_maven.pl
Executable file
38
scripts/localize_maven.pl
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use File::Slurp;
|
||||
|
||||
sub localize_maven {
|
||||
my ($file) = @_;
|
||||
|
||||
die "File does not exist: $file\n" unless -f $file;
|
||||
die "Not a Gradle file (must end in .gradle or .gradle.kts): $file\n"
|
||||
unless $file =~ /\.(gradle|gradle\.kts)$/;
|
||||
|
||||
my $content = read_file($file);
|
||||
my $modified_content = $content;
|
||||
|
||||
$modified_content =~ s{
|
||||
(maven\s*\{) # Start of maven block
|
||||
((?:[^{}]*|\{[^{}]*\})*?) # Content of the block (non-greedy)
|
||||
(\}) # Closing brace
|
||||
}{
|
||||
# Check if the block contains plugins.gradle.org
|
||||
my $block = $1 . $2 . $3;
|
||||
$block =~ /plugins\.gradle\.org/ ? $block : "mavenLocal()"
|
||||
}gexs;
|
||||
|
||||
if ($modified_content ne $content) {
|
||||
# Write the modified content back to the file
|
||||
open(my $out, '>', $file) or die "Can't open $file: $!";
|
||||
print $out $modified_content;
|
||||
close $out;
|
||||
|
||||
print "Processed file: $file\n";
|
||||
}
|
||||
}
|
||||
|
||||
localize_maven($ARGV[0]) if @ARGV;
|
||||
|
||||
1;
|
||||
@@ -22,8 +22,8 @@ set -e
|
||||
function localize_maven {
|
||||
# Replace custom Maven repositories with mavenLocal()
|
||||
find ./* -name '*.gradle' -type f -print0 | xargs -0 \
|
||||
sed -n -i \
|
||||
-e '/maven {/{:loop;N;/}$/!b loop;/plugins.gradle.org/!s/maven .*/mavenLocal()/};p'
|
||||
perl "$rootdir/scripts/localize_maven.pl"
|
||||
|
||||
# Make gradlew scripts call our Gradle wrapper
|
||||
find ./* -name gradlew -type f | while read -r gradlew; do
|
||||
echo -e '#!/bin/sh\ngradle "$@"' >"$gradlew"
|
||||
@@ -116,6 +116,10 @@ rustup target add aarch64-linux-android
|
||||
rustup target add x86_64-linux-android
|
||||
cargo install --vers 0.26.0 cbindgen
|
||||
|
||||
## Install perl modules
|
||||
echo 'Installing File::Slurp perl module...'
|
||||
sudo perl -MCPAN -e 'install File::Slurp'
|
||||
|
||||
# Fenix
|
||||
# shellcheck disable=SC2154
|
||||
pushd "$fenix"
|
||||
|
||||
Reference in New Issue
Block a user