Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Contributing Code to DSpace Software

Table of Contents
minLevel2

Excerpt

This page provides specific guidelines on how to contribute your code to DSpace, and details how the code review/acceptance process works.


Note

Developers - See also the Developer Guidelines and Tools for hints/tips on using popular IDEs to develop with DSpace.

Contribution Quick Checklist

This page has a lot of great information on it. But, if you just need the high level overview, here it is. NOTE: the checkboxes below are here for "decorative" purposes, and aren't really intended to be used. If you'd like, and you find it helpful, you may print this page and then check off each step as you proceed with your contribution. Happy coding, and please ask for help if you find you need it!

  •  Create a ticket in the DSpace Issue Tracker (describe your contribution, how to use it, and perhaps some use cases).
  •  Make sure your code adheres to our Code Style Guide (only required for DSpace 7.x or above)
  •  Write unit/integration tests per our Code Testing Guide (only required for DSpace 7.x or above)
  •  Submit your code via GitHub. Please submit a GitHub Pull Request (see GitHub's "About Pull Requests", or our notes on Development with Git), which references your newly created ticket by number (e.g. DS-1234). 
    • Ideally submit your code or ideas early on before it turns into a massive project.  Larger code changes take a very long time to understand, review and test.  Starting the discussion early (or breaking the changes up into several smaller changes) can make it much easier to get your code accepted.
  •  Review your own code. Does it follow our Contribution Checklist? Does it need Documentation? If you are using any third party tools/APIs, do they all have an acceptable Open Source License (see Licensing of Contributions)? The Committers will also be reviewing these aspects of your code, but if you can catch these gaps or issues up front it can speed up the process of correcting them.
  •  Respond to feedback. If the Committers ask questions or make suggestions for changes, please try to be responsive. The Committers are all volunteers and are trying to help as best we can, but the process moves more quickly if you can try to be responsive as well.
  •  Help rework/update code as needed. If suggestions for changes are made, if you can rework the code, it speeds up the process. If you submitted your code as a Pull Request, you can just quickly add changes/updates to the branch linked to from your Pull Request.
  •  Ask questions. If there is a long delay in the Committers responding, or if you aren't sure of the status of your contribution, please ask. We'd be glad to explain whether the delay is just because we are all busy, or if there's something else we are waiting on.
  •  Pay attention to release deadlines. As the next DSpace release approaches, the Committers will announce a "Contribution Deadline" for the upcoming release (usually the release schedule & deadlines are emailed to all lists in July/August). In order to keep releases on-time, the Committers must set a date after which they can no longer accept new feature contributions.  Although you may add code contributions year round, they will only be considered for a specific release if they are contributed before that release's contribution deadline.

Overview of Code Approval Process – How to get your Code into DSpace!

0. Share Early, Share Often!

The overriding mantra is share early, share often. Here are a few things to consider before you begin working on your code:

  • For Larger Initiatives/Codebases: If you are building out a much larger project, we highly recommend notifying the community of the work early on via an email to dspace-devel@googlegroups.com (or via one of the weekly Developer Meetings).  This has several benefits:
    • Ensures you achieve your goals in a way that is consistent with the DSpace architecture and plans of the rest of the community. 
    • Minimizes the chances of a scenario where you have invested a large amount of time and effort into a body of code that does not fit in with the DSpace architecture or the consensus of the community.
    • This can help find collaborators or get early feedback.
  • Develop incrementally; try and implement and contribute a basic form of your feature as soon as possible, rather than aiming to implement a complete and 'polished' solution. This will help ensure you're on the right track with regards to the rest of the DSpace community and platform. The sooner your code is part of the core code base, the less time you will have to spend 'chasing' the main code base, i.e. keeping your changes up-to-date with that core code base.
  • Obtain the DSpace code using GitHub (see also Development with Git). This will make code management much easier. It's very simple to do; see Developer Guidelines and Tools.
  • Read 81953128 (this page), Code Style Guide and Code Testing Guide to ensure you are following DSpace conventions. This will ensure your code is more likely to be immediately accepted as part of out-of-the-box DSpace.
  • Ensure that any third-party tools/libraries that you plan to utilize are released under compatible open source licenses. See the 81953128 section below.

1. Make your code available (preferably in GitHub) and create a ticket in our Issue Tracker

Once your code is ready, you must make your code available to the DSpace Committers Group for review. The easiest way for us to review your code is by putting your code into GitHub. Then, submit a "Pull Request" to our GitHub repository (see also Development with Git). Alternatively, if you are not yet comfortable with GitHub, you may create a patch (and upload it to our DSpace Issue Tracker). However, please be aware that submitting a patch may delay the review process (see below note)

In either case, you must also create a new ticket in our DSpace Issue Tracker. This ensures that the DSpace Developers are notified of your contribution, and acts as a place for us to comment on the work or make suggestions for improvements.

Info
titleCode Standards

Code contributions that meet certain standards are much more likely to be accepted immediately. For a list of our current standards, please read through the 81953128 section below.


Note
titleTo ensure your contribution is reviewed more quickly, send us a GitHub Pull Request!

When making a code contribution, at the very least you should create a new ticket in our DSpace Issue Tracker. In that issue you should provide information as to why you feel this code is a worthwhile contribution (e.g. describe the bug it fixes or a use case that it meets). You can submit your code as an attachment to that ticket (not recommended, see below), or submit it as a Pull Request to our GitHub code repository (highly recommended).

We highly recommend submitting a GitHub Pull Request (see Development with Git for hints/tips), which mentions the ticket by number (e.g. DS-1234).  In order to add any new feature to DSpace, a Pull Request must be generated (by someone). So, if you are able to create and submit the Pull Request, it makes it that much easier for the Committers to review and accept the changes. If you are unable to create the Pull Request, then the review process may be delayed, as we will need to locate a "steward" for your contribution, i.e. someone who is willing and able to create the necessary Pull Request on your behalf.


Note
titleKeep in Mind the "Feature Contribution Deadline" for the Next Release

When the next release of DSpace is getting close, the Committers will set a "Feature Contribution Deadline" date, after which no new feature submissions will be accepted for that release. The reason for this is that the Committers need time to review & stabilize the current code before the next release can be completed. Make sure to check the Next Release Status page for details on when the next "Feature Contribution Deadline" is. Please note that bug fixes are still accepted after the "Code Contribution Deadline", as they will help to stabilize the upcoming release.

2. Code Review Process

Once the code is made available, the Committers Group will take time to review the work and provide feedback/comments. Usually, one (or more) committers who are interested in this work will contact you and discuss any feedback we have, and whether or not there would need to be some general changes before we could accept it. Some patches/features are readily accepted (because they are stable and look good), others may require more work (if there are concerns or issues that Committers notice).

Info
titleCode Review Timeframe

The timeframe of a code review will vary, based on how much time the Committers have. Smaller changes may be reviewed within days, while larger changes/features may take many weeks to do a full review. All Committers are volunteers and only have a small amount of time to provide to the project in a given week. We will make every effort to get back to you with feedback within a few weeks. But, if you haven't heard anything, feel free to ask!


Note
titleWhat are we reviewing for?

When we review your code, we are mostly ensuring it generally follows our 81953128. However, there are a few other things we generally check for:

  • The code is well commented (e.g. has JavaDocs)
  • The code follows our Code Style Guide (only required for DSpace 7.x and above)
  • The code provides Unit and/or Integration Tests (see Code Testing Guide)
  • The code is stable and has no stability or security concerns
  • The code is properly using existing APIs, etc.
  • The code is not too specific to one institution's local policies or workflows. (I.e. we will review the code to ensure it looks to be generally useful to most institutions, or configurable enough such that others can change it to match their own local policies/workflows)
  • Any third-party tools/libraries used by your code have compatible open source licenses. See 81953128

3. Reworking Code (if necessary) & Next Steps

After the code review & feedback, interested Committers may help you to rework the code (if needed). They'll also provide you with next steps on getting the code into DSpace. If it can be accepted immediately, it will be. If not, we'll try to help figure out the best route forward.

Info
titleHow you can help speed up the process

As our Committers are all volunteers, they don't always have the time to rework code changes for you. If you want your code change accepted in a timely manner, please offer to make the changes yourself (otherwise your patch suggestion may wait in a "holding queue" until someone has enough time to work on any necessary fixes).


Note
titleCommunicate, Communicate, Communicate

If you are unsure of next steps, please let us know by adding a comment to your issue in the Issue Tracker. Communication is absolutely necessary to ensure that we can help you rework anything that needs reworking. If we don't hear from you, we'll assume you are hard at work. So, if you've run into issues, please let us know! If, locally, you don't have the time or expertise to do the rework that is necessary, also let us know. We can try to locate a community developer to help out, and/or ask both the Committers Team and the DSpace Community Advisory Team if they know of any interested developers with time to spare.

4. Acceptance!

Once your code is accepted, it will be released in the next version of DSpace software! It is time to celebrate, as your name will be added to the prestigious list of DSpace Contributors!

Code Contribution Standards

Code contributions that meet the following standards are much more likely to be accepted. If you don't understand any of these standards, please contact us – we'll be glad to explain or help.

Contribution Checklist

When you contribute to DSpace, please be sure that your submission adheres to the points in this checklist. The DSpace Committers need you to do this to keep quality of the DSpace code high and their work manageable.

  1. Any changes must be compliant with the supported version of Java (e.g. for DSpace 7, Java 11 compliance is required)
  2. Your code must adhere to our Java Code Style Guide. Most major IDEs can easily import our Checkstyle configurations to ensure alignment with this code style.
    1. Your code should be well commented with Javadoc (required for all classes, public methods and larger private/protected methods).
  3. Your code must provide unit/integration tests for new features, bug fixes or improvements per our Code Testing Guide.
  4. If your contribution adds new third-party tools or libraries, they must adhere to licensing requirements to be included. Refer to the 81953128 below
  5. User interface changes must be internationalised (see the Internationalization Support (I18nSupport) guide)
  6. User interface changes should have a W3C WCAG Conformance Level of "Double-A"
  7. Your code must come with Documentation. Minimally, technical documentation must be part of the system docs – see 81953128 below. Ideally, we'd also like User/Usage Documentation.
  8. Ideally, new features should be configurable (i.e. generalized so as to not be specific to one institution's needs/use cases).  Any new configurations should have sane defaults which can be overridden (as needed) in a site's local.cfg file

<?xml version="1.0" encoding="utf-8"?>
<html>
See also the Guide+to+Developing+with+DSpace.

Contribution Checklist

When you contribute to DSpace, please be sure that your submission adheres to the points in this checklist. The DSpace committers need you to do this to keep quality of the DSpace code high and their work manageable.

  • Your contribution needs to be a patch against the SVN trunk.

Ensure the code is commented and correctly formatted (you can use Eclipse's format function to do that or a tool like Jacobe). Refer to the*Coding Conventions below

Your contribution must adhere to licensing requirements to be included. Refer to the*Licensing of Contributions below

  • User interface patches must be internationalised (see the I18nSupport guide)
  • User interface patches must be XHTML-compliant and have a W3C WAI Conformance Level of "Double-A"

Technical and User on-line help as part of the patch. Technical documentation must be part of the system docs – see*Documentation Contributions below.

  • Examples or Use Cases should be submitted to help committers understand and adequately test the patch prior to applying it to the core code

Patches must be small diffs (no large all encompassing patches!) using the unified output format (see*Submitting a Patch below for flags)

  • Any new features must be configurable. Be careful in particular with the `dspace.cfg` file. Make sure you only patch this if you change involved new configuration parameters in it, and make sure you have good default values for them. Don't accidentally include your own local configuration parameters (e.g. host name etc) in the patch! If the new feature is in any way specific to a particular application (e.g., open access, theses), it should be switched off by default
  • If you add new configuration parameters, name them appropriately. Also, they should not be required to be in dspace.cfg – if the parameters are omitted, DSpace should continue to operate as before.

...

  1. .
  2. Add appropriate WARN, INFO and DEBUG-level logging. Use the included Apache Log4J toolkit, in concert with the

...

  1. org.apache.

...

  1. logging.

...

  1. log4j.

...

  1. LogManager class to do this.

...

    1. Provide informative log statements and/or the entire Throwable exception. For example, "log.error('My custom error message', e)" is more useful than "log.error(e.getMessage(), e)"
  1. Retain backwards compatibility where possible. If there are questions/concerns about this, let us know. There are always exceptions.
  2. No

...

  1. database schema changes unless absolutely necessary

...

  1. to support a new feature. See 81953128 below.
  2. If your code makes changes to the database schema or content, and you are patching more than one branch (for example, dspace-6_x and master), see 81953128 below.

If there are questions/concerns about any of these guidelines, let us know on the 'dspace-devel' list. We are willing to make exceptions in some areas, if exceptions are necessary.

...

Note
titleAttempt to Follow all Guidelines

Omission of one or more of these items is likely to result in the

...

*Create the patch file and submit to the DSpace JIRA System

Coding Conventions

Your code needs to follow the Sun Java code conventions with the following minor modifications:

  • Curly braces must be on new lines.
  • Source files must have a copy of the copyright HP and MIT notice and BSD license at the top (see below) - see also Copyright and Licensing.
  • You must use 4-space tabulation.
  • 'else' should be on a new line. 'else if' stays on one line.
  • Users of the Eclipse IDE can have eclipse do the formatting automatically using this profile: - dspace-eclipse-format.xml. See the Eclipse section below for details of how to apply this profile.

...

a request for further work. See the Overview of Code Approval Process above, for more information.

Licensing of Contributions

Any third-party libraries (e.g. JARs / Maven Dependencies) required to compile or run DSpace must be included. The license of any required jar/dependency MUST be compatible with BSD; it . It must not prevent any commercial use of DSpace, nor have any impact on the rest of the code by its inclusion. It is not acceptible acceptable to require additional downloads of JARs/dependencies to make DSpace compile or function.

Non-Java third-party web frameworks or tools (e.g. XSLT, CSS, Images) should follow these same licensing guidelines.

Examples of acceptable licenses:

Examples of unacceptable licenses:

Note
titleWhy is GPL (and similar) unacceptable?

DuraSpace feels it is important for commercial entities and service providers to be able to customize the entire codebase and redistribute/repackage/sell it in a binary form. GPL licenses prevent this, as noted in the following FAQ questions:

In addition, the Apache Software Foundation has a good explanation of why they are also forced to avoid GPL-based (copyleft) licenses because of its one-way compatibility with Apache License 2.0:

Div
stylepadding-left:30px; color:grey

"This licensing incompatibility applies only when some Apache project software becomes a derivative work of some GPLv3 software, because then the Apache software would have to be distributed under GPLv3. 

We avoid GPLv3 software because merely linking to it is considered by the GPLv3 authors to create a derivative work. We want to honor their license. Unless GPLv3 licensors relax this interpretation of their own license regarding linking, our licensing philosophies are fundamentally incompatible. This is an identical issue for both GPLv2 and GPLv3."

While DSpace is released under BSD licensing, the same issues exist between BSD licenses and GPL-based licenses.

JDBC drivers for databases are an exception since:

  • They must correspond to the database version and not the DSpace version.
  • They are not required for DSpace to compile and run; a variety of databases, including open source databases, may be used.

If you are including new jars or later versions of existing jars, you need to include the associated license file for inclusion in the lib/license directory. The README file in the lib directory must also be updated as part of the patch to describe the jar and identify the jar version.

...

Database schema changes 

Database schema changes will be done only on major revisions to the source; this is when the version number takes the form x.y 0 (e.g. 12.30). When making patches which cause schema changes, it is necessary to update all of the relevant SQL/migration files with your sequences, tables, views etc. (in /dspace/etc):

  • database_schema.sql - the SQL to create the database from scratch
  • clean-database.sql - the SQL to remove all the parts of the database
  • database_schema_<old version>-<new version>.sql (e.g. database_schema_11_12.sql) - the SQL to update the <old version> of the schema to the <new version>
  • update-sequences.sql - the SQL to ensure that sequences are set correctly

Documentation Contributions

Follow exactly the same procedure as above; the documentation resides in the {dspace/docs/docbook} directory.

As of 1.5.1, the documentation is now in docbook. The docbook sources are used to
generate both HTML and PDF forms of the documentation. There are many docbook tutorials available, but you may find it easiest to just review the existing documentation source for an example of what you want to achieve.

Submitting the Patch

Submit the patch to the DSpace JIRA System. Be sure to describe the modification, including the numbers of any bug/feature request items that the patch relates to.

What Happens Next

Once you have produced and submitted your patch to the DSpace JIRA System it must be reviewed, tested and approved by one of the committers (see DSpaceContributors for more details). Comments regarding the submission can be posted to JIRA and you will receive email notification of any feedback. If and when your patch becomes stable and approved it will be integrated into the DSpace code base by one of the committers.

During the normal release cycle a feature freeze will be declared for a given date, and normally only patches submitted prior to that date will be considered for the upcoming release. Any patches submitted after this will be in time for the feature freeze of the following release. The date of submitted patches may be flexible depending on the time available for testing and integration and the urgency/usefulness of the patch. Patches which fix bugs will also generally be considered until much closer to the final release date.

 

  • For Database migrations/management, we use FlywayDB
    • The migration scripts are available in the dspace-api source code under the org.dspace.storage.rdbms.sqlmigration package: https://github.com/DSpace/DSpace/tree/master/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration
    • Each new migration script should be named "V[version]_[date]__[description].sql", where [version] is the DSpace version supporting this change, [date] is the date of the change, and [description] includes the associated ticket number and brief description of the migration. For example: "V5.0_2014.09.26__DS-1582_Metadata_For_All_Objects.sql".
    • NOTE: Whenever possible, please avoid modifying migration scripts from a prior DSpace release.  Flyway does not compare modified scripts against the current database structure, so it will not modify tables based on modifications to existing migration scripts. Therefore, modifications to existing scripts may result in some (or all) DSpace users having to manually run those database changes during their next upgrade.
      • Instead, where possible, consider creating a migration script (in SQL or Java) that will run just before (or after) the script you are looking to modify.
  • If your database migration adds new sequences, then you should also be sure to update the update-sequences script at:
    • [dspace-src]/dspace/etc/[db-type]/update-sequences.sql
    • At this time, this updated-sequences script is maintained outside of the database migrations as it is useful to run manually after large restorations, etc.

Patching multiple branches
Anchor
Patching multiple branches
Patching multiple branches

When you patch the same issue in multiple branches, database changes require special attention.  This advice applies to both schema changes and content changes.

  • FlywayDB migrations are cumulative.  You should depend on changes that you made in the earliest affected branch to be available in later branches, and only do further migrations in later branches if additional changes are needed.
  • When patching a branch earlier than 5_x, you will need to provide an SQL script or a tool to be run manually.  5_x and later patches should still depend on these manual updates, and you should document the need to run them before allowing automatic migrations to run.
  • If the schema was already changed between branches, and those changes affect the same tables that you are updating, depend also on the existing upgrade process to make those changes for you.  For example:  if you make database changes to table T in branch X, and the upgrade from X to Y changes the schema for T, you don't need to rewrite your changes for branch Y because the upgrade already took care of that difference.

Documentation Contributions

All new features require documentation before they will be accepted. You may send us code before documentation is completed, but we will be unable to accept that code into DSpace until it is properly documented. Bug fixes may not require documentation, unless they somehow make a modification which changes how DSpace functions.

All documentation is now built in a special section of the Wiki at DSpace Documentation. Therefore, the best way to send us Documentation is to actually create a new page(s) in this DSpace Wiki. You should link these Wiki page(s) to your issue in our DSpace Issue Tracker. We'll move them over into the official DSpace Documentation area once you code has been accepted.</html>