|
| 1 | +# Contributing to Google Analytics Plugin for dotCMS |
| 2 | + |
| 3 | +Thank you for your interest in contributing! We welcome pull requests that improve the plugin. |
| 4 | + |
| 5 | +## Pull Requests |
| 6 | + |
| 7 | +#### Before You Start |
| 8 | + |
| 9 | +1. **Keep changes focused** - One feature/fix per PR |
| 10 | +2. **Fork the repository** - Work on your own fork |
| 11 | + |
| 12 | +#### Development Setup |
| 13 | + |
| 14 | +1. **Fork and clone the repository** |
| 15 | + ```bash |
| 16 | + git fork https://github.com/dotCMS/google-analytics.git |
| 17 | + cd google-analytics |
| 18 | + ``` |
| 19 | + |
| 20 | +2. **Create a feature branch** |
| 21 | + ```bash |
| 22 | + git checkout -b feature/your-feature-name |
| 23 | + # or |
| 24 | + git checkout -b fix/issue-description |
| 25 | + ``` |
| 26 | + |
| 27 | +3. **Set up your development environment** |
| 28 | + - JDK 11 or higher |
| 29 | + - Gradle (included via wrapper) |
| 30 | + - A running dotCMS instance for testing (local or Docker) |
| 31 | + |
| 32 | +4. **Build the plugin** |
| 33 | + ```bash |
| 34 | + ./gradlew clean jar |
| 35 | + ``` |
| 36 | + |
| 37 | + The JAR will be in `build/libs/google-analytics-X.X.X.jar` |
| 38 | + |
| 39 | +#### Making Changes |
| 40 | + |
| 41 | +1. **Write clean, readable code** |
| 42 | + - Follow existing code style and patterns |
| 43 | + - Add comments for complex logic |
| 44 | + - Keep methods focused and concise |
| 45 | + |
| 46 | +2. **Test your changes** |
| 47 | + - Build the plugin: `./gradlew jar` |
| 48 | + - Upload to a dotCMS instance |
| 49 | + - Test with real Google Analytics data |
| 50 | + - Verify OSGi bundle loads without errors |
| 51 | + - Test Velocity viewtool functionality |
| 52 | + |
| 53 | +3. **Update documentation** |
| 54 | + - Update README.md if you changed functionality |
| 55 | + - Add/update code comments |
| 56 | + - Document new viewtool methods or parameters |
| 57 | + |
| 58 | +4. **Commit your changes** |
| 59 | + ```bash |
| 60 | + git add . |
| 61 | + git commit -m "Brief description of changes |
| 62 | +
|
| 63 | + Longer explanation of what changed and why. |
| 64 | + Include any breaking changes or migration notes." |
| 65 | + ``` |
| 66 | + |
| 67 | + **Commit message guidelines:** |
| 68 | + - Use present tense ("Add feature" not "Added feature") |
| 69 | + - Be concise but descriptive |
| 70 | + - Reference issues when applicable (`Fixes #123`) |
| 71 | + |
| 72 | +#### Submitting Your PR |
| 73 | + |
| 74 | +1. **Push to your fork** |
| 75 | + ```bash |
| 76 | + git push origin feature/your-feature-name |
| 77 | + ``` |
| 78 | + |
| 79 | +2. **Create a Pull Request** |
| 80 | + - Go to the [repository](https://github.com/dotCMS/google-analytics) |
| 81 | + - Click "New Pull Request" |
| 82 | + - Select your fork and branch |
| 83 | + - Fill out the PR template with: |
| 84 | + - **What changed** - Clear description of changes |
| 85 | + - **Why** - The problem this solves |
| 86 | + - **Testing** - How you tested the changes |
| 87 | + - **Breaking changes** - Any compatibility issues |
| 88 | + - **Related issues** - Link to related issues |
| 89 | + |
| 90 | +3. **Address review feedback** |
| 91 | + - Be responsive to comments |
| 92 | + - Make requested changes in new commits |
| 93 | + - Ask questions if feedback is unclear |
| 94 | + |
| 95 | +## Development Guidelines |
| 96 | + |
| 97 | +### Code Style |
| 98 | + |
| 99 | +- **Java**: Follow standard Java conventions |
| 100 | +- **Indentation**: 4 spaces (no tabs) |
| 101 | +- **Braces**: Opening brace on same line |
| 102 | +- **Naming**: |
| 103 | + - Classes: `PascalCase` |
| 104 | + - Methods/variables: `camelCase` |
| 105 | + - Constants: `UPPER_SNAKE_CASE` |
| 106 | + |
| 107 | +### OSGi Considerations |
| 108 | + |
| 109 | +When adding dependencies: |
| 110 | + |
| 111 | +1. **Check if dotCMS already provides it** - Use `compileOnly` if yes |
| 112 | +2. **Bundle third-party libraries** - Add to `osgiLibs` configuration |
| 113 | +3. **Update Import-Package** - Exclude bundled packages from imports |
| 114 | +4. **Test OSGi wiring** - Verify bundle loads in clean dotCMS instance |
| 115 | + |
| 116 | +Example from `build.gradle`: |
| 117 | +```gradle |
| 118 | +dependencies { |
| 119 | + compileOnly('com.dotcms:dotcms:23.01.10') { transitive = true } |
| 120 | + implementation (group: 'your.library', name: 'artifact', version: '1.0.0') |
| 121 | + osgiLibs (group: 'your.library', name: 'artifact', version: '1.0.0') |
| 122 | +} |
| 123 | +
|
| 124 | +'Import-Package': ''' |
| 125 | + !your.library.*, |
| 126 | + javax.*, |
| 127 | + com.dotcms.*, |
| 128 | + ... |
| 129 | +''' |
| 130 | +``` |
| 131 | + |
| 132 | +### Testing Checklist |
| 133 | + |
| 134 | +Before submitting a PR, verify: |
| 135 | + |
| 136 | +- [ ] Plugin builds without errors: `./gradlew clean jar` |
| 137 | +- [ ] JAR uploads successfully to dotCMS |
| 138 | +- [ ] OSGi bundle starts without errors (check logs for "Starting Google Analytics OSGI plugin") |
| 139 | +- [ ] Viewtool is available in Velocity (`$analytics`) |
| 140 | +- [ ] Can create analytics request and query GA4 data |
| 141 | +- [ ] No breaking changes to existing Velocity code (or documented if necessary) |
| 142 | +- [ ] Works with dotCMS 23.01.10 and newer |
| 143 | + |
| 144 | +## Versioning |
| 145 | + |
| 146 | +This plugin follows [Semantic Versioning](https://semver.org/): |
| 147 | + |
| 148 | +- **Major (X.0.0)**: Breaking changes |
| 149 | +- **Minor (0.X.0)**: New features, backward compatible |
| 150 | +- **Patch (0.0.X)**: Bug fixes, backward compatible |
| 151 | + |
| 152 | +**IMPORTANT:** Bump the version in `build.gradle` for each PR that should trigger a new release: |
| 153 | + |
| 154 | +```gradle |
| 155 | +version = '0.4.2' // Increment for your changes |
| 156 | +``` |
| 157 | + |
| 158 | +When merged to main, GitHub Actions will: |
| 159 | +1. Check if release `v0.4.2` exists |
| 160 | +2. If not, build the JAR and create the release |
| 161 | +3. If yes, skip release creation (no duplicates) |
| 162 | + |
| 163 | +**Always bump the version** to ensure your changes are trackable in releases. |
| 164 | + |
| 165 | +## Release Process |
| 166 | + |
| 167 | +Releases are automated via GitHub Actions: |
| 168 | + |
| 169 | +1. PR is merged to `main` |
| 170 | +2. GitHub Actions builds the plugin |
| 171 | +3. Creates a GitHub release with the JAR attached |
| 172 | +4. Tags the release with version from `build.gradle` |
| 173 | + |
| 174 | +Only maintainers can merge to `main` and trigger releases. |
| 175 | + |
| 176 | +## Questions? |
| 177 | + |
| 178 | +- **General questions**: [dotCMS Community Forums](https://dotcms.com/forums) |
| 179 | +- **dotCMS development**: [dotCMS Developer Docs](https://dotcms.com/docs) |
| 180 | + |
| 181 | +## License |
| 182 | + |
| 183 | +By contributing, you agree that your contributions will be licensed under the same terms as the project. |
| 184 | + |
| 185 | +--- |
| 186 | + |
| 187 | +Thank you for contributing to make dotCMS better! 🎉 |
0 commit comments