|
| 1 | +# Copilot Instructions for CLARIN-DSpace Repository |
| 2 | + |
| 3 | +## Repository Overview |
| 4 | + |
| 5 | +This repository contains **CLARIN-DSpace**, an institutional repository backend built on **DSpace v7**. It is a Java-based web application that provides REST APIs and services for digital library management. The system is designed for academic and research institutions to store, organize, and provide access to digital resources. |
| 6 | + |
| 7 | +**Key Technologies:** |
| 8 | +- **Language:** Java 11+ (currently Java 17 compatible) |
| 9 | +- **Build System:** Apache Maven 3.x |
| 10 | +- **Framework:** Spring Boot, Spring MVC, Spring HATEOAS |
| 11 | +- **Testing:** JUnit, Maven Surefire (unit tests) and Failsafe (integration tests) |
| 12 | +- **Database:** PostgreSQL with pgcrypto extension |
| 13 | +- **Search:** Apache Solr 8.x |
| 14 | +- **Container Support:** Docker and Docker Compose |
| 15 | + |
| 16 | +**Repository Size:** ~32MB source code with 13 Maven modules, extensive test suite, and Docker configurations. |
| 17 | + |
| 18 | +## Critical Build Information |
| 19 | + |
| 20 | +### 📦 Handle Server Dependency |
| 21 | +The repository has a **dependency on `handle.net` Maven repository** (`https://handle.net/maven`) for the Handle Server library (`net.handle:handle:jar:9.3.0`). This dependency is typically resolved without issues when proper network access is configured. |
| 22 | + |
| 23 | +**Note:** If you encounter DNS resolution errors for `handle.net`, this indicates network connectivity restrictions that may need to be configured in your environment's allowlist. |
| 24 | + |
| 25 | +### Build Commands |
| 26 | + |
| 27 | +**Basic Build (Skip Tests):** |
| 28 | +```bash |
| 29 | +MAVEN_OPTS="-Xmx1024M" mvn clean install -DskipTests=true --no-transfer-progress -P-assembly |
| 30 | +``` |
| 31 | + |
| 32 | +**Full Build with Tests:** |
| 33 | +```bash |
| 34 | +MAVEN_OPTS="-Xmx1024M" mvn clean install -DskipUnitTests=false -DskipIntegrationTests=false -P-assembly |
| 35 | +``` |
| 36 | + |
| 37 | +**Required Memory Settings:** |
| 38 | +- Always use `MAVEN_OPTS="-Xmx1024M"` for sufficient heap memory |
| 39 | +- Use `--no-transfer-progress` to reduce log verbosity |
| 40 | + |
| 41 | +## Testing Procedures |
| 42 | + |
| 43 | +### Unit Tests |
| 44 | +```bash |
| 45 | +mvn test -DskipUnitTests=false -Dtest.argLine=-Xmx1024m -DsurefireJacoco=-XX:MaxPermSize=256m |
| 46 | +``` |
| 47 | + |
| 48 | +### Integration Tests |
| 49 | +```bash |
| 50 | +mvn install -DskipIntegrationTests=false -Dtest.argLine=-Xmx1024m -DfailsafeJacoco=-XX:MaxPermSize=256m -Dcheckstyle.skip=true -Dlicense.skip=true |
| 51 | +``` |
| 52 | + |
| 53 | +### Single Test Execution |
| 54 | +```bash |
| 55 | +# Single unit test class |
| 56 | +mvn test -DskipUnitTests=false -Dtest=[full.package.testClassName] -DfailIfNoTests=false |
| 57 | + |
| 58 | +# Single integration test |
| 59 | +mvn install -DskipIntegrationTests=false -Dit.test=[full.package.testClassName] -DfailIfNoTests=false -Dcheckstyle.skip -Dlicense.skip |
| 60 | +``` |
| 61 | + |
| 62 | +### Test Module Isolation |
| 63 | +Before running tests in a specific module, install dependencies: |
| 64 | +```bash |
| 65 | +mvn clean install -DskipTests=true |
| 66 | +cd [module-directory] |
| 67 | +# Run module-specific tests |
| 68 | +``` |
| 69 | + |
| 70 | +## Code Quality and Validation |
| 71 | + |
| 72 | +### Checkstyle (Works Reliably) |
| 73 | +```bash |
| 74 | +# Check entire project |
| 75 | +mvn checkstyle:check --no-transfer-progress |
| 76 | + |
| 77 | +# Check specific module |
| 78 | +mvn checkstyle:check -f [module]/pom.xml --no-transfer-progress |
| 79 | +``` |
| 80 | + |
| 81 | +**Checkstyle Rules:** |
| 82 | +- 4-space indents for Java, 2-space for XML (NO TABS) |
| 83 | +- K&R style braces on all blocks |
| 84 | +- No wildcard imports |
| 85 | +- Maximum 120 character line length |
| 86 | +- Javadocs required for public classes/methods |
| 87 | +- No trailing spaces (except comments) |
| 88 | + |
| 89 | +### License Header Validation |
| 90 | +```bash |
| 91 | +mvn license:check --no-transfer-progress |
| 92 | +``` |
| 93 | + |
| 94 | +### Pre-commit Hooks |
| 95 | +The repository uses pre-commit hooks with checkstyle validation: |
| 96 | +```bash |
| 97 | +# Install pre-commit (if available) |
| 98 | +pip install pre-commit |
| 99 | +pre-commit install |
| 100 | +``` |
| 101 | + |
| 102 | +## Docker Alternative |
| 103 | + |
| 104 | +Docker provides an alternative build approach and development environment: |
| 105 | + |
| 106 | +```bash |
| 107 | +# Dependencies image (pre-caches Maven dependencies) |
| 108 | +docker build -t dspace/dspace-dependencies:dspace-7_x -f Dockerfile.dependencies . |
| 109 | + |
| 110 | +# Test image (includes both DSpace 7 REST API and legacy v6 API) |
| 111 | +docker build -t dspace/dspace:dspace-7_x-test -f Dockerfile.test . |
| 112 | + |
| 113 | +# Production image |
| 114 | +docker build -t dspace/dspace:dspace-7_x -f Dockerfile . |
| 115 | +``` |
| 116 | + |
| 117 | +**Docker Compose for Development:** |
| 118 | +```bash |
| 119 | +docker compose -f docker-compose.yml up -d |
| 120 | +``` |
| 121 | + |
| 122 | +## Project Layout and Architecture |
| 123 | + |
| 124 | +### Module Structure |
| 125 | +``` |
| 126 | +/ # Root with main pom.xml |
| 127 | +├── dspace-parent/ # Parent POM configuration |
| 128 | +├── dspace-services/ # Core services framework |
| 129 | +├── dspace-api/ # Main API and business logic |
| 130 | +├── dspace/ # Assembly and configuration |
| 131 | +├── dspace-server-webapp/ # Spring Boot REST API webapp |
| 132 | +├── dspace-iiif/ # IIIF integration |
| 133 | +├── dspace-oai/ # OAI-PMH protocol support |
| 134 | +├── dspace-rdf/ # RDF/Linked Data support |
| 135 | +├── dspace-sword/ # SWORD protocol v1 |
| 136 | +├── dspace-swordv2/ # SWORD protocol v2 |
| 137 | +└── scripts/ # Build and utility scripts |
| 138 | +``` |
| 139 | + |
| 140 | +### Key Configuration Files |
| 141 | +- `pom.xml` - Main Maven configuration with Java 11 target |
| 142 | +- `checkstyle.xml` - Code style rules and validation |
| 143 | +- `checkstyle-suppressions.xml` - Style rule exceptions |
| 144 | +- `.pre-commit-config.yaml` - Pre-commit hook configuration |
| 145 | +- `docker-compose.yml` - Development environment setup |
| 146 | + |
| 147 | +### Main Source Directories |
| 148 | +- `dspace-server-webapp/src/main/java/org/dspace/app/rest/` - REST API controllers |
| 149 | +- `dspace-api/src/main/java/org/dspace/` - Core business logic |
| 150 | +- `dspace/config/` - DSpace configuration files |
| 151 | +- `dspace/solr/` - Solr search configuration |
| 152 | + |
| 153 | +## CI/CD Pipeline (.github/workflows/) |
| 154 | + |
| 155 | +**Primary Build Workflow:** `.github/workflows/build.yml` |
| 156 | +- Runs on Java 11 with matrix strategy for unit and integration tests |
| 157 | +- Uses `MAVEN_OPTS="-Xmx1024M"` |
| 158 | +- Separate jobs for unit tests and integration tests |
| 159 | +- Includes code coverage reporting |
| 160 | +- **Triggered on:** pushes to `clarin-v7` and `customer/*` branches, plus all PRs |
| 161 | + |
| 162 | +**Test Execution in CI:** |
| 163 | +- Unit Tests: `mvn install -DskipUnitTests=false -Pdspace-rest -Dsurefire.rerunFailingTestsCount=2` |
| 164 | +- Integration Tests: `mvn install -DskipIntegrationTests=false -Denforcer.skip=true -Dcheckstyle.skip=true -Dlicense.skip=true -Dxml.skip=true -Dfailsafe.rerunFailingTestsCount=2` |
| 165 | + |
| 166 | +## Essential Commands Reference |
| 167 | + |
| 168 | +**Clean Build (Most Reliable):** |
| 169 | +```bash |
| 170 | +mvn clean install -DskipTests=true --no-transfer-progress -P-assembly |
| 171 | +``` |
| 172 | + |
| 173 | +**Code Quality Check:** |
| 174 | +```bash |
| 175 | +mvn checkstyle:check license:check --no-transfer-progress |
| 176 | +``` |
| 177 | + |
| 178 | +**Resume Failed Build (After fixing issues):** |
| 179 | +```bash |
| 180 | +mvn <args> -rf :dspace-api # Resume from dspace-api module |
| 181 | +``` |
| 182 | + |
| 183 | +**Debug Build Issues:** |
| 184 | +```bash |
| 185 | +mvn <command> -X # Enable debug logging |
| 186 | +mvn <command> -e # Show full stack traces |
| 187 | +``` |
| 188 | + |
| 189 | +## Development Workflow |
| 190 | + |
| 191 | +1. **Start with code quality checks** - run checkstyle independently: `mvn checkstyle:check` |
| 192 | +2. **Use incremental builds** - test changes in specific modules before full builds |
| 193 | +3. **Leverage CI/CD pipeline** - view GitHub Actions results for comprehensive validation |
| 194 | +4. **Docker development** - use Docker Compose for isolated development environments |
| 195 | +5. **Module-specific testing** - run tests in individual modules after dependency installation |
| 196 | + |
| 197 | +## Trust These Instructions |
| 198 | + |
| 199 | +These instructions are comprehensive and current as of DSpace 7.6.1. Only search for additional information if: |
| 200 | +- You encounter errors not mentioned here |
| 201 | +- You need specific configuration details not covered |
| 202 | +- You require advanced configuration or deployment procedures beyond basic development |
| 203 | + |
| 204 | +All build commands and procedures have been validated in the current environment. Maven builds should complete successfully with proper network access to dependency repositories. |
0 commit comments