Skip to content

Commit 2e8727d

Browse files
aschemanclaude
andcommitted
Move Maven repositories to ./maven subdirectory
Introduce MAVEN_PROJECTS_DIR variable (default: maven) to support Maven project checkouts in a subdirectory instead of the root. Changes: - common-functions.sh: Add MAVEN_PROJECTS_DIR, use ${root} prefix for all paths (projects, logs, develocity), add MAVEN_REPO_LOCAL_OPT - repo-start, repo-checkout-specific-branches: cd into maven dir - run-maven, run-jqa: Use MAVEN_REPO_LOCAL_OPT from common-functions - CLAUDE.md: Document new directory structure and variables - .gitignore: Simplify for new structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e725f6d commit 2e8727d

File tree

7 files changed

+40
-32
lines changed

7 files changed

+40
-32
lines changed

.gitignore

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
.idea/
2-
# Maven directories
3-
core/
4-
doxia/
5-
misc/
6-
plexus/
7-
plugins/
8-
shared/
9-
sisu/
10-
site/
11-
sources/
12-
studies/
13-
svn/
2+
# Maven directories (new location via symlink)
3+
maven
144
# Our stuff
15-
.repo/
165
.envrc*
17-
.m2/repository/
186
.sdkmanrc
197
jqassistant/store*
208
logs/*

CLAUDE.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
Maven Support & Care Tools - an automation toolkit for managing, building, and analyzing the Apache Maven multi-repository ecosystem. Uses the `repo` tool to manage 100+ Apache Maven repositories (manifest hosted at [maven-sources](https://github.com/apache/maven-sources)). Repositories are checked out directly into this directory with `.repo` at the root.
7+
Maven Support & Care Tools - an automation toolkit for managing, building, and analyzing the Apache Maven multi-repository ecosystem. Uses the `repo` tool to manage 100+ Apache Maven repositories (manifest hosted at [maven-sources](https://github.com/apache/maven-sources)). Repositories are checked out into the `./maven` directory (a symlink to external storage) with `.repo` at `maven/.repo`.
88

99
## Prerequisites
1010

@@ -20,11 +20,11 @@ Maven Support & Care Tools - an automation toolkit for managing, building, and a
2020
# Initialize and sync repositories from maven-sources manifest
2121
./bin/repo-start
2222

23-
# Execute command across all repos
24-
repo forall -c "${PWD}/bin/gh-subscribe"
23+
# Execute command across all repos (from maven/ directory)
24+
cd maven && repo forall -c "${PWD}/../bin/gh-subscribe"
2525

2626
# Execute on subset (by group)
27-
repo forall -r 'core' -c "${PWD}/bin/some-script"
27+
cd maven && repo forall -r 'core' -c "${PWD}/../bin/some-script"
2828
```
2929

3030
### Building Projects
@@ -77,7 +77,8 @@ USE_DEVELOCITY=true ./bin/run-maven clean install
7777

7878
| Variable | Description | Default |
7979
|----------|-------------|---------|
80-
| `PROJECTS` | Space-separated list of project paths | Contents of `.repo/project.list` |
80+
| `MAVEN_PROJECTS_DIR` | Directory containing Maven project checkouts | `maven` |
81+
| `PROJECTS` | Space-separated list of project paths | Contents of `${MAVEN_PROJECTS_DIR}/.repo/project.list` |
8182
| `USE_DEVELOCITY` | Enable Develocity build scans | `false` |
8283
| `FAIL_FAST` | Exit on first build failure | `false` |
8384
| `PREVIEW_LOGLINES` | Lines of log to show on failure | `0` |

bin/common-functions.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
# INPUT VARIABLES
1515
# - dir: (Required, injected by caller) The directory path injected by the caller. This is used to determine the root directory.
1616
# - ONLY_MAVEN: (Optional) If set to true (default), only Maven-based projects will be processed.
17-
# - PROJECTS: (Optional) Space-separated list of projects to process, defaulting to the contents of `.repo/project.list`.
17+
# - MAVEN_PROJECTS_DIR: (Optional) Directory containing Maven project checkouts, defaults to `maven`.
18+
# - PROJECTS: (Optional) Space-separated list of projects to process, defaulting to the contents of `${MAVEN_PROJECTS_DIR}/.repo/project.list`.
1819
# - PREVIEW_LOGLINES: (Optional) Number of log lines to preview in case of a build failure.
1920
# - FAIL_FAST: (Optional) If set to true, the script will exit immediately upon a build failure.
2021
#
@@ -38,15 +39,22 @@
3839
#
3940

4041
: "${ONLY_MAVEN:=true}"
42+
: "${MAVEN_PROJECTS_DIR:=maven}"
4143
: "${SETTINGS:=${PWD}/settings.xml}"
4244

4345
# shellcheck disable=SC2034 disable=SC2154
44-
# root is used in other scripts, dir is injeted by the caller
46+
# root is used in other scripts, dir is injected by the caller
4547
root=$(readlink -f "${dir}/..")
46-
[[ -z "${PROJECTS:-}" ]] && PROJECTS="$(cat ${root}/.repo/project.list)"
48+
[[ -z "${PROJECTS:-}" ]] && PROJECTS="$(cat ${root}/${MAVEN_PROJECTS_DIR}/.repo/project.list)"
4749
noof_projects=$(echo "${PROJECTS}" | wc -w | sed -e 's/ //g')
4850
counter=0
4951

52+
# Only set maven.repo.local if not already configured in MAVEN_OPTS
53+
MAVEN_REPO_LOCAL_OPT=""
54+
if [[ ! "${MAVEN_OPTS:-}" =~ maven.repo.local ]]; then
55+
MAVEN_REPO_LOCAL_OPT="-Dmaven.repo.local=${root}/.m2/repository"
56+
fi
57+
5058
exec_mvn() {
5159
project=$1
5260
shift
@@ -58,36 +66,39 @@ exec_mvn() {
5866
shift
5967
goals=${*}
6068

61-
if ! test -r "${project}/pom.xml" && eval "${ONLY_MAVEN}"; then
69+
# Full path to project directory (under MAVEN_PROJECTS_DIR)
70+
project_dir="${root}/${MAVEN_PROJECTS_DIR}/${project}"
71+
72+
if ! test -r "${project_dir}/pom.xml" && eval "${ONLY_MAVEN}"; then
6273
echo "${project} is not a Maven project (${counter}/${noof_projects})"
6374
return
6475
fi
6576

66-
test ! -d "${project}" && echo "${project} does not exist" >&2 && return
67-
mkdir -p "logs/${project}"
77+
test ! -d "${project_dir}" && echo "${project} does not exist" >&2 && return
78+
mkdir -p "${root}/logs/${project}"
6879
ext=""
6980
case "${project}" in
7081
"core/maven")
7182
ext=" (no extension)"
7283
;;
7384
*)
74-
mkdir -p "${project}/.mvn"
75-
ln -f develocity/*.xml "${project}/.mvn"
85+
mkdir -p "${project_dir}/.mvn"
86+
ln -f "${root}/develocity"/*.xml "${project_dir}/.mvn"
7687
;;
7788
esac
7889

7990
mvn="mvn"
8091
with="with"
81-
if test -r "${project}/mvnw"; then
92+
if test -r "${project_dir}/mvnw"; then
8293
mvn="./mvnw"
8394
else
8495
with="without"
8596
fi
86-
logs="logs/${project}/${task}-$$-${counter}.log"
97+
logs="${root}/logs/${project}/${task}-$$-${counter}.log"
8798
echo -n "${project} (${counter}/${noof_projects}), a Maven project ${with} wrapper, build (logs: '${logs}') "
8899
set +e
89100
(
90-
cd "${project}"
101+
cd "${project_dir}"
91102
# shellcheck disable=SC2086
92103
${mvn} -B -s "${SETTINGS}" ${opts} ${goals} 2>&1
93104
) > "${logs}"

bin/repo-checkout-specific-branches

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
set -eu -o pipefail
44

55
: "${BRANCH:=$(git branch --show-current)}"
6+
: "${MAVEN_PROJECTS_DIR:=maven}"
7+
8+
# Change to maven projects directory
9+
cd "${MAVEN_PROJECTS_DIR}"
610

711
# THIS IS REALLY A UGLY HACK - DO NOT USE IT IN PRODUCTION - ITS JUST A SHOWCASE
812
declare -A branches

bin/repo-start

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ set -eu -o pipefail
55
: "${GITHUB_ORGANIZATION:=unknown}"
66
: "${WORKING_BRANCH:=master}"
77
: "${BRANCH:=$(git branch --show-current)}"
8+
: "${MAVEN_PROJECTS_DIR:=maven}"
9+
10+
# Change to maven projects directory
11+
cd "${MAVEN_PROJECTS_DIR}"
812

913
# Use latest repo if available
1014
PATH=".repo/repo:${PATH}"

bin/run-jqa

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jqa_common_opts() {
116116
local extension="${1:-}"
117117
echo "
118118
${MVN_OPTS:-}
119-
-Dmaven.repo.local=${root}/.m2/repository
119+
${MAVEN_REPO_LOCAL_OPT}
120120
-Djqassistant.maven.reuse-store=false
121121
-Djqassistant.store.uri=${store_uri}
122122
-Djqassistant.configuration.locations=${root}/.jqassistant${extension}.yml

bin/run-maven

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fi
3939
dir=$(dirname "${0}")
4040
source "${dir}/common-functions.sh"
4141

42-
opts="-Dmaven.repo.local=${root}/.m2/repository"
42+
opts="${MAVEN_REPO_LOCAL_OPT}"
4343

4444
goals="${*}"
4545

0 commit comments

Comments
 (0)