Codex containers block outbound HTTPS calls. Plain curl calls work, but Maven’s own HTTP client can’t reach Maven Central, so your build dies on the first dependency download, with a ‘Non-resolvable parent POM … Network is unreachable’ that seems like it’ll never go away.
Naturally, the struggle to look for documentation is harder than the struggle to find it, but ultimately the fix transpired to be to route all outbound traffic through Codex’s built-in proxy (proxy:8080). Because curl and apt use the proxy automatically (thanks to transparent iptables rules) they succeed, which makes the Maven error look mysterious. The script below worked for me (drop into Environment/Setup script in Codex):
#!/usr/bin/env bash
set -euxo pipefail
###############################################################################
# 1. Install Maven (Java 21 & Node 20 set in Preinstalled Packages)
###############################################################################
apt-get update -qq
apt-get install -yqq maven
###############################################################################
# 2. Point tools to Codex’s proxy (HTTP & HTTPS)
###############################################################################
export http_proxy="http://proxy:8080"
export https_proxy="$http_proxy"
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$http_proxy"
# Maven-specific proxy block for completeness
mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<'EOF'
<settings>
<proxies>
<!-- HTTPS tunnel via Codex proxy -->
<proxy>
<id>codex-https</id>
<active>true</active>
<protocol>https</protocol>
<host>proxy</host>
<port>8080</port>
</proxy>
<!-- Fallback for any plain-HTTP endpoints -->
<proxy>
<id>codex-http</id>
<active>true</active>
<protocol>http</protocol>
<host>proxy</host>
<port>8080</port>
</proxy>
</proxies>
</settings>
EOF
###############################################################################
# 3. Pre-warm Maven & Node caches while the network is open
###############################################################################
mvn -B -q dependency:go-offline
if [ -f package.json ]; then
npm ci --silent
fi