Scalable layout for Java projects - from simple tools to complex frameworks
WARNING: A project without a GitHub repository is NOT a project - it's just files pretending to matter.
Before ANY other setup:
# Create GitHub repository FIRST
gh repo create ProjectName --public --description "What this project does"
cd ProjectName
git init
git add .
git commit -m "Initial commit: Project structure"
git push -u origin mainWhy this is NON-NEGOTIABLE:
- Local-only repositories have ZERO safety - one disk failure = total loss
- No collaboration possible without remote repository
- No history preservation without real version control
- No credibility as "professional" code without public accessibility
- Local git is just playing pretend - only remote repositories actually exist
- GitHub repository FIRST - Not optional, not "later", FIRST
- Scalable base pattern - Same structure from simple to complex projects
- Everything in README.md - All functionality documented and reachable
- Shell script launchers - Never manual
javacommands - Classes with source - .class files in package directories (simple) or managed by build system (complex)
- Complete documentation - If it's not documented, it doesn't exist
- Optional components - Add complexity only when needed
ProjectName/
├── .git/ # MANDATORY - Real version control
├── .gitignore # MANDATORY - Prevent accidental commits
├── README.md # Complete project documentation
├── compile.sh # Build system (simple or complex)
├── tool1.sh # Shell launcher for primary tool
├── package1/ # At least one package required
│ ├── MainTool.java # Primary functionality
│ ├── UtilityClass.java # Supporting classes
│ └── *.class # Compiled classes (simple projects)
├── api/ # Generated .api files
│ └── package_package1.api # Package overview for framework understanding
├── reports/ # ALL outputs go here, never project floor
└── old/ # Archives (never delete, always archive)
ProjectName/
├── configure.sh # [OPTIONAL] Dependency detection & environment setup
├── javasetup.sh # [OPTIONAL] Professional BBTools argument parsing
├── memdetect.sh # [OPTIONAL] Cross-platform memory detection
├── build/ # [OPTIONAL] Complex build systems only
├── lib/ # [OPTIONAL] External dependencies
├── package2/ # [OPTIONAL] Additional packages
│ ├── SpecializedTool.java
│ └── *.class
├── marketing/ # [OPTIONAL] Domain-specific packages
├── testCases/ # [OPTIONAL] Comprehensive test infrastructure
├── data/ # [OPTIONAL] Test datasets and samples
├── docs/ # [OPTIONAL] Extended documentation
├── plans/ # [OPTIONAL] Development planning artifacts
├── prompts/ # [OPTIONAL] Development templates
├── validation_results/ # [OPTIONAL] Quality assurance outputs
├── debug_temp/ # [OPTIONAL] Temporary debugging files
└── temp_test/ # [OPTIONAL] Temporary test artifacts
- Source + Compiled: .java and .class files in same package directory
- Scripts: All .sh files at project root
- Outputs: reports/ directory, never project floor
- Documentation: README.md links to everything else
- APIs: api/ directory with package_X.api for every package
For straightforward tools with minimal argument parsing:
#!/bin/bash
# Standard directory resolution
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Help function
usage() {
echo "Usage: $0 input.file [options]"
echo "Description: What this tool does"
echo " --help Show this help"
echo " -Xmx<mem> Set memory (e.g., -Xmx2g)"
}
# Basic argument processing
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
usage; exit 0
fi
# Simple memory management
XMX="-Xmx1g"
for arg in "$@"; do
case $arg in -Xmx*) XMX="$arg";; esac
done
# Execute with basic classpath
CLASSPATH="$DIR/package1:$DIR/package2:$DIR/*"
java $XMX -ea -cp "$CLASSPATH" package1.ToolClassName "$@"For projects needing sophisticated argument parsing (see ShellScriptGuide.md):
#!/bin/bash
# BBTools-style directory resolution
pushd . > /dev/null
DIR="${BASH_SOURCE[0]}"
while [ -h "$DIR" ]; do
cd "$(dirname "$DIR")"
DIR="$(readlink "$(basename "$DIR")")"
done
cd "$(dirname "$DIR")"
DIR="$(pwd)/"
popd > /dev/null
# Source professional auxiliary scripts (if present)
if [ -f "$DIR/javasetup.sh" ]; then
source "$DIR/javasetup.sh"
source "$DIR/memdetect.sh"
# Professional argument parsing
parseJavaArgs "$@"
setEnvironment
# Execute with professional setup
java $EA $EOOM $SIMD $XMX $XMS -cp "$BUILD_CLASSPATH" tools.ToolClassName "$@"
else
# Fallback to simple pattern
XMX="-Xmx1g"
for arg in "$@"; do
case $arg in -Xmx*) XMX="$arg";; esac
done
java $XMX -ea -cp "$DIR/*" tools.ToolClassName "$@"
fiFor basic projects with standard Java dependencies:
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Simple compilation - .class files in package directories
find "$DIR" -name "*.java" -path "*/package*" -exec javac -cp "$DIR/*" {} +
if [ $? -eq 0 ]; then
echo "✅ Compilation successful - .class files in packages/"
else
echo "❌ Compilation failed"
exit 1
fiFor projects with external dependencies (Eclipse JDT, etc.):
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Source configuration if available
if [ -f "$DIR/projectname-env.sh" ]; then
source "$DIR/projectname-env.sh"
elif [ -f "$DIR/configure.sh" ]; then
echo "Running first-time configuration..."
sh "$DIR/configure.sh"
source "$DIR/projectname-env.sh"
fi
# Complex compilation with dependency management
javac -cp "$BUILD_CLASSPATH" -d "$DIR/build" "$DIR"/package*/*.java
if [ $? -eq 0 ]; then
echo "✅ Compilation successful - classes in build/ or packages/"
# Generate API files if tools available
if [ -f "$DIR/build/tools/ApiWriter.class" ] || [ -f "$DIR/package*/ApiWriter.class" ]; then
echo "Generating API files..."
java -cp "$BUILD_CLASSPATH" tools.ApiWriter "$DIR"/package*/ "$DIR/api/"
fi
else
echo "❌ Compilation failed"
exit 1
fiEvery project README.md follows this structure:
# ProjectName
*Brief description of what it does*
## Quick Start
```bash
sh projectName/compile.sh # Build all tools
sh projectName/tool1.sh input.file # Use primary tool
sh projectName/tool2.sh --help # Get help for any tool- tool1.sh - Primary functionality description
- tool2.sh - Secondary functionality description
- tools/ - Java source and compiled classes
- api/ - Generated API files for framework understanding
- docs/ - Extended documentation
- reports/ - All outputs go here
[Complete examples with expected inputs and outputs]
## Documentation Requirements
1. **README.md** - Complete usage documentation
2. **Package APIs** - api/package_X.api for every package (generated, not fabricated)
3. **Shell script help** - Every .sh responds to --help
4. **Examples** - Working examples with real inputs/outputs
## API Generation Patterns
### Simple Projects
Basic package API generation using standard tools:
```bash
# Generate package overview (non-private elements)
sh projectName/apiwriter.sh package1/ api/package_package1.api
# Generate individual class details (all elements including private)
sh projectName/apiwriter.sh package1/MainTool.java api/MainTool.api
Comprehensive framework API generation:
# Generate comprehensive project overview
sh projectName/apiwriter.sh . project.api --include-all-packages
# Generate package-specific APIs
sh projectName/apiwriter.sh tools/ api/package_tools.api
sh projectName/apiwriter.sh marketing/ api/package_marketing.api
# Handle interface assertion bug if needed
java -da -cp "$BUILD_CLASSPATH" tools.ApiWriter marketing/ api/package_marketing.apiMyProject/
├── README.md
├── compile.sh # Basic javac compilation
├── mytool.sh # Simple shell script
├── mypackage/
│ ├── MyTool.java
│ └── MyTool.class
├── api/
│ └── package_mypackage.api
├── reports/
└── old/
MyProject/
├── README.md
├── configure.sh # Added for Eclipse JDT
├── myproject-env.sh # Generated by configure.sh
├── compile.sh # Now handles complex classpath
├── javasetup.sh # Professional argument parsing
├── memdetect.sh # Cross-platform memory detection
├── mytool.sh # Now uses auxiliary scripts
├── specialtool.sh # Additional tools
├── build/ # Managed by complex build system
├── lib/ # External dependencies
├── mypackage/ # Original package
├── specialized/ # New domain-specific package
├── testCases/ # Added testing infrastructure
├── data/ # Test datasets
├── api/
│ ├── project.api # Comprehensive overview
│ ├── package_mypackage.api
│ └── package_specialized.api
├── reports/
└── old/
- Base structure never changes - same core directories
- Add optional components - don't modify existing patterns
- Shell scripts detect complexity - fallback to simple patterns if auxiliary scripts missing
- Documentation scales - README.md grows but maintains same structure
When your project needs external dependencies (Eclipse JDT, specialized libraries):
#!/bin/bash
# configure.sh - Auto-detect dependencies and create environment
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Configuring project environment..."
# Detect Eclipse JDT (example for AST processing)
ECLIPSE_JDT=""
for eclipse_path in "/c/Users/$USER/eclipse/"*"/eclipse/plugins" "/opt/eclipse/plugins" "$HOME/eclipse/plugins"; do
if [[ -d "$eclipse_path" ]] && [[ -f "$eclipse_path/org.eclipse.jdt.core_"*.jar ]]; then
ECLIPSE_JDT="$eclipse_path/*"
echo "Found Eclipse JDT: $eclipse_path"
break
fi
done
if [ -z "$ECLIPSE_JDT" ]; then
echo "WARNING: Eclipse JDT not found. Some features may not work."
echo "Install Eclipse JDT or place jars in lib/ directory."
fi
# Generate environment configuration
cat > "$DIR/$(basename "$DIR")-env.sh" << EOF
# Auto-generated environment configuration
export BUILD_CLASSPATH="$DIR/build:$DIR/*:$ECLIPSE_JDT"
export ECLIPSE_DETECTED="${ECLIPSE_JDT:+true}"
export PROJECT_ROOT="$DIR"
EOF
echo "Configuration complete. Environment saved to $(basename "$DIR")-env.sh"- ❌ Local-only git repositories (worthless without remote backup)
- ❌ "I'll push to GitHub later" (later never comes, disk failures do)
- ❌ Manual
java -cpcommands (use shell scripts) - ❌ Inconsistent structure between simple/complex (use base pattern + optional components)
- ❌ Fabricated documentation (use generation tools)
- ❌ Outputs on project floor (use reports/)
- ❌ Searching for functionality (read documentation)
- ❌ Complex patterns for simple projects (start simple, scale up)
- ✅ GitHub repository created and code pushed
- ✅ Base directory structure (package/, api/, reports/, old/)
- ✅ Simple compile.sh using javac
- ✅ Basic shell scripts with simple argument parsing
- ✅ README.md documents all functionality
- ✅ Package .api files generated
- ✅ All outputs in reports/
- ✅ Regular commits with meaningful messages
- ✅ GitHub repository with proper branching strategy
- ✅ Base structure + optional components (lib/, build/, testCases/, etc.)
- ✅ configure.sh for dependency detection
- ✅ Complex compile.sh with BUILD_CLASSPATH
- ✅ Professional shell scripts with auxiliary script integration
- ✅ Comprehensive APIs (project.api + package-specific)
- ✅ Testing infrastructure and validation
- ✅ CI/CD integration (GitHub Actions for tests/builds)
# After EVERY significant change
git add .
git commit -m "Meaningful description of what changed and why"
git push
# Never let local commits accumulate
git status # Should show "Your branch is up to date with 'origin/main'"# Compiled class files
*.class
# Build directories
build/
target/
out/
# IDE files
.idea/
.vscode/
*.iml
.project
.classpath
.settings/
# Package files
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar
# Logs and databases
*.log
*.sqlite
# OS files
.DS_Store
Thumbs.db
# Project-specific
reports/*
!reports/.gitkeep
temp_*/
debug_*/
*-env.sh- "But I'm just testing" - Test code becomes production code
- "It's a small project" - Small projects become large projects
- "I work alone" - You won't always, and future-you needs history
- "My disk is reliable" - No disk is reliable enough for irreplaceable code
Universal structure for all Java projects - GitHub repository FIRST, then scalable patterns from simple tools to complex frameworks