Even though some informations are valid independently of the OS, this documentation was written for windows.
git
should be installed, and we recommend the use of IntelliJ for Java and PyCharm for Python development
Having your repositories version controlled allows for reusability and reproducibility. It is essential for collaborative work (and less if you are sure than you will be the only one working on your project). It can also help to find bugs.
Please follow these conventions when creating a repository containing code
Type | Name | Short Name |
---|---|---|
ActionBars | {name} ActionBar | ijab-... |
Plugins | {name} Plugin | ijp-... |
Macros | {name} Macro | ijm-... |
Scripts | {name } Script | ijs-... |
XTensions | {name} XT | xt-... |
Python Projects | {name} Python | py-... |
Use dash (-
) as separators, and non capital letters. For instance ijp-bigdataviewer-segment
.
We are using github.
Oli created an account for the BIOP on GitHub. That way our public work is more visible and more professional. All BIOP members are administrators and can add more people and create repositories.
git rm -r --cached some-directory
git commit -m 'Remove the now ignored directory "some-directory"
git push origin master
We develop at the BIOP several packages designed for Fiji and QuPath, thus being Java based.The section below describes version control and continuous integration for tools that belong to the scijava ecosystem (ImageJ/Fiji, and QuPath).
The procedure described below will help you to:
The procedure described below is aimed at making java repositories in the scijava ecosystem. Other things exist for python, c, etc.
Briefly, you will have to abide by certain rules when creating a repository. These rules will allow github, via github actions, to build your repo for each commit, potentially test it (if you put tests), and also make its current state (SNAPSHOT
versions) and releases available through the maven.scijava.org web server.
What this does NOT do, is handling Fiji update sites - manual uploads are still required.
The BIOP organization has 'secrets' shared with scijava maven, and thus all repos created and present in the BIOP organization can use CI. This is not the case if your repository is on your personal github account. So to enable CI on a personal, you have to give ownership to BIOP before (otherwise you need to contact a scijava administrator).
To change the ownership of a github repository, go to the github
Settings
tab and chooseTransfer ownership
from theDanger Zone
.
Enter "BIOP". On your local computer, update your repository's remote url :
$ git remote set-url origin <biop_remote_url>
The procedure for CI is explained below. Some parts have to be setup once, some parts one time for each repository (enabling CI for a repo), and some actions have to be performed each time you want to publish a release, once CI has been enabled.
scijava-scripts
repository once at the proper file hierarchy locationThe repository https://github.com/scijava/scijava-scripts contains all the useful scripts used for continuous integration. These scripts will have to be executed in order to enable CI for a repository or to make a new release. This repository needs to be present locally in your computer.
git clone https://github.com/scijava/scijava-scripts
and - it will ease the execution of these scripts - put the scripts repo at the same hierarchy as all the other repos you want to enable CI:Path
System environment variableAdd to the Path
system environment variable the :
C:\Program Files\Jetbrains\IntelliJ\Java\Jdk\
or C:\Program Files\Java\jdk1.8.0_xxx
)C:\Program Files\JetBrains\IntelliJ IDEA Community Edition YYYY.M\plugins\maven\lib\maven3\bin
)Add or edit a JAVA_HOME
system environment variable that points to:
C:\Program Files\Jetbrains\IntelliJ\Java\Jdk\
or C:\Program Files\Java\jdk1.8.0_xxx
)You can do that in git bash with a line like:
export JAVA_HOME="C:\Users\chiarutt\.jdks\corretto-1.8.0_392"
and confirm that the new variable is set (at least for this session of bash) with
echo $JAVA_HOME
Preparation before enabling CI
Here we assume that you created a java repository that uses a scijava template (maven based), like https://github.com/BIOP/ijp-template-ij2 or https://github.com/imagej/example-imagej2-command
Mainly, the pom.xml
file needs to be tidy and ready for CI. A good way to check that it is the case, is to look for a good pom example file. For instance check the one in https://github.com/BIOP/ijp-kheops, and modify your pom accordingly.
A few things to check:
All dependencies should be publicly available, either through scijava maven (https://maven.scijava.org/ - mainly imagej stuff) or through maven central (https://search.maven.org/), or through another publicly available maven repository.
The dependency versions should : not be a SNAPSHOT dependency (because SNAPSHOTS can be overriden, the build is not reproducible) + their versions should be declared in the properties part of the pom.xml file of the repository.
DO NOT WRITE:
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
WRITE:
<properties>
...
<reflections.version>0.9.11</reflections.version>
</properties>
...
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>${reflections.version}</version>
</dependency>
This allows the versions to be managed / checked and overriden if necessary by scijava maven plugins.
mvn javadoc:javadoc
in the intellij terminal (this can take a while). Then correct all the errors (this can take a while also). Warning can be ignored ( thus you can type mvn javadoc:javadoc | grep error
to avoid displaying warnings, but that works only with git bash, not in the windows terminal). Usually you have issues with special characters (<
, >
, @
, etc...). You need to replace them with their html representation &whatever
, see https://dev.w3.org/html5/html-author/charref)Actionify - enable CI through Github Actions
you may want to update your
.gitignore
file. Again, check the.gitignore
file of https://github.com/BIOP/ijp-kheops. You can directly copy paste it into your repo.
Windows may have issues with file permission trakcing. The best is to not track them. For that, execute locally:
git config core.fileMode false
github-actionify.sh
in simulation mode to see if everything looks right:git bash here
. Then type ../scijava-scripts/github-actionify.sh
.You may have some issues displayed that you need to fix. If everything looks alright, you can run this command 'for real':
../scijava-scripts/github-actionify.sh -f
to run the actionification for realOnce your repo has been actionified, each time you want to push a release, you need to:
git bash here
. Then type ../scijava-scripts/release-version.sh
. You are asked which version that you want to release. Usually, you are working on a version like v1.2.3-SNAPSHOT, and the script will release the version v1.2.3 and will automatically commit modification in order to update your repo to v1.2.4-SNAPSHOT, where you can continue your development. If this doesn't work, push to GitHub and ask for help!Check maven.scijava.org
to see if the package has been correctly uploaded.
Contrary to the Fiji ecosystem, QuPath uses gradle
for its dependency management.
This means that scijava-scripts
will not work because what takes the role of the bill of materials pom.xml
file is not there. Instead, a file called build.gradle
is present, and it can contain both some data but also some executable code.
In order to make a new extension for QuPath, what we recommend is:
.git
folderbuild.gradle
file and start to write the extension with java codeYou can then use the github actions workflow to execute a release on scijava maven. Two workflows are available, one to put a SNAPSHOT version, one to put a release version.
In practice, when you develop, you should always have a version with a -SNAPSHOT
suffix. For instance 1.5.3-SNAPSHOT
. If you need to make the repository available to other repositories, execute the release github action workflow.
When you want to make a release:
1.5.3
in a commit1.5.4-SNAPSHOT
and push the repo on githubThe BIOP is much less experienced with python packages. Johannes Soltwedel nicely introduced me (Nicolas) to some basics of Python project 'shaping' and PyPI publishing. Is a python a_thing
repo is published on PyPI, it can be installed via pip install a_thing
.
PyPI is not ideal regarding the solving of dependency issues, but it's also easier than to publish on a conda channel.
There's no BIOP python package published yet, but the goal is to publish abba_python
on PyPI. So while I'm struggling with this process, I'm writing it in here.
Assumption:
Pre-requisite:
From your base environment, do:
conda create -n cookie
conda activate cookie
pip install cookiecutter
Cookie cutter can generate the skeleton of a project that will be "easily" publishable on PyPI. For that, it takes a template from github (we could create a BIOP template, but so far I used the one from the documentation).
Execute cookiecutter:
cookiecutter
You will be prompted to enter some information from your future repository (name, license, email, etc.). And at the end, a new folder will be generated that will be used for development. It's the created folder that you need to open in PyCharm for instance.
If you already wrote some code, the best is to create a new folder with cookie cutter, and then copy and paste your code into the newly shaped folder.
.
Do not forget the __init__.py
files, crucial to define what's in the future PyPI
repository.
You should now be, I think, not in the cookie environment, but in the dev environment, the one that can run your project/repository. But I'm not sure.
When placed in your projectory directory, execute pip install -e .
: that's an experimental local installation of the repo. A new .egg-info
folder shows up in your code folder. When it's successful, you are ready for the next step.
You need to pip install build
. Then execute python -m build
. This should create a build
folder in your repository, contains a tar.gz
file. You can unpack, looks what's inside and make sure that nothing is missing.
pip install twine
(once, I did it on the cookie env)twine check dist/*
twine upload dist/*
Then check on PyPI, something should have shown up or be updated.
After a round of commits, you may want to release a new version. If the settings are correct in setup.cfg
, you may need to pip install bumpversion
and then simply run bumpversion patch
or bumpversion minor
or bumpversion major
depending on the kind of version update you want to do.
Good luck! Usually, you may have folder path issues that should be resovable via googling or chatgpting and editing the setup.cfg
file.
pom.xml
In your projec pom.xml
add this to the end (before </project>
)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<outputDirectory>${project.basedir}</outputDirectory>
<reportOutputDirectory>${project.basedir}</reportOutputDirectory>
<destDir>docs</destDir>
</configuration>
</plugin>
</plugins>
</build>
You will now have a javadoc
engtry under your Maven Plugins section.
Run
javadoc:javadoc
. Unless you have errors in your JacaDocs comments, it should create thedocs
folder, which you can then commit to yourmain
branch
Configure your GitHub Pages
Settings
Pages
on the left menuDeploy from a branch
/docs