Hi Paul,

Paul Hammant wrote:

> OK, so I'm a documenter of Google's Monorepo (one biiiig ass trunk) and
> it's usage of shell scripts to subset the checkout for speedy development:
> 
>    http://paulhammant.com/2014/01/06/googlers-subset-their-trunk/
>    https://trunkbaseddevelopment.com/monorepos/
> 
> For Maven to be used with a scripted use of Subversion or Git's
> sparse-checkout (or Perforce's client spec), it'd been to be more like
> Bazel/Blaze or Buck, in that sub-modules are *not* forward declared, they
> are discovered/calculated/inferred somehow.
> 
> In pom.xml instead of -
> 
>   <modules>
>         <module>one</module>
>         <module>two</module>
>    </modules>
> 
> We'd need -
> 
>   <modules>
>         <search>recursively</search>
>    </modules>
> 
> Or -
> 
>   <modules>
>         <defined-in>.full-module-list.txt</defined-in>
>         <!-- made by
>               find . -name "pom.xml" | sed 's/\/pom.xml//' >
> .full-module-list.txt
>               after the sparse-checkout modification of working copy -->
>    </modules>
> 
> Thoughts?
> 
> Any questions?
> 
> - Paul H
> 
> PS - I'm a solid Maven user since 2003.

we did something like that just with bash scripts and it boils down to to a 
simple shell function. In the follwing example it creates module entries for 
all direct subdirectories containing a pom.xml file, but you might easily 
adjust this to some expression using globs, find or a list in a file.

==================== %< ================

function createBuilder()
{
    local artifactId
    local path

    artifactId=${1##*/}
    cat > "$1"/pom.xml <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<project
    xmlns="http://maven.apache.org/POM/4.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>

    <modelVersion>4.0.0</modelVersion>
    <groupId>builder</groupId>
    <artifactId>$artifactId</artifactId>
    <packaging>pom</packaging>
    <version>x-SNAPSHOT</version>
    <name>Builder $artifactId</name>
    
    <modules>
EOF
    while read path; do
        if [ -f "$path" ]; then
            continue
        fi
        path=${path##*/}
        cat >> "$1"/pom.xml <<EOF
        <module>$path</module>
EOF
    done < <(ls -d "$1"/*)
    cat >> "$1"/pom.xml <<EOF
    </modules>
</project>
EOF
}

==================== %< ================

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to