Apache Maven is a very popular build and dependency management tool in the Java open source ecosphere. I did some tests to find out if it can handle compiled Free Pascal / Delphi units and found it easy to implement. So it would be possible to
- release open source libraries precompiled for Free Pascal (or Delphi) in a public Maven repository
- include metadata in this repository which contains dependency information
- use Maven on the command line to download the open source library from the public repository, and automatically resolve all dependencies
- local repositories, working as proxies, could be used to cache frequently used binaries
- automatic checksum generation and verification (provided by Maven) would reduce the risk of downloading corrupted binaries
- source code and even documentation files could be provided with the binaries
- binaries can be provided with or without debug information
- continuous integration servers like Hudson, TeamCity or CruiseControl can be used to build projects whenever changes have been submitted to the source control system and notify developers about build errors
This way of dependency management could be very beneficial for open source projects which use many third party libraries with complex dependencies. It would avoid typical conflicts caused by using wrong versions.
For the developer, the workflow for editing and building a project would be reduced to a minimum:
- checkout the project source from internal version control system
- edit source file(s)
- run
mvn package
to automatically download all required third party libraries (precompiled units) if they are not yet in the workstation's local repository
- compile and run
The only additional file for Apache Maven which is required in the project folder is the POM.XML file containing the project information.
Edit: while Maven is usable for some of the required tasks, implementing a solution like Maven in native Free Pascal would have some advantages: no Java SDK required, support for all development platforms where Free Pascal is available, maintenance and plugin development in Pascal.
Usage of a Maven-like tool would not be helpful for open source projects only - commercial projects could access and use the artifacts in public Maven repositories in the same way as well.
Maven features are listed at http://maven.apache.org/maven-features.html
Update:
one use case could be the build of Lazarus, where Maven would download all required libraries and invoke the compiler with the necessary build path arguments. Changes in the dependencies on lower levels would be propagated automatically up to the parent build.
Possible benefits:
- less time needed to set up a new work
station, no manual installation of
third party libraries required
- less errors caused by wrong library
versions, detection of version
conflicts (for example if two
libraries depend on different
versions of a third library)
- artifacts which are created inhouse
can be added to the local maven
repository and shared between
developers and project, central
storage of all artifacts with
metadata
- builds are reproducible, just by
using the same source and project
metadata file (pom.xml)
- can reduce development time and
increase project stability
Update #2: FPMake
the FPMake build system for Free Pascal seems to be a tool with much potential, in many details it is quite similar to Maven:
- FPMake is a pascal based build system developed for and distributed with FPC
- FPMake standardizes the building by defining some limits like standard directories
- the command
fppkg <packagename>
will look in a database for the package, extract it, and then compile fpmake.pp and run it
- it has standard build targets (clean, build, install, ...)
- it can create a 'manifest' file suitable for import into a repository (like
mvn deploy
or mvn install
), the manifest is an XML file which looks very similar to a pom.xml in Maven:
FPMake manifest file:
<packages>
<package name="my-package">
<version major="0" minor="7" micro="6" build="1"/>
<filename>my-package-0.7.6-1.zip</filename>
<author>my name</author>
<license>GPL</license>
<homepageurl>http://www.freepascal.org/</homepageurl>
<email>myname@freepascal.org</email>
<description>this is the package description</description>
<dependencies>
<dependency>
<package packagename="rtl"/>
</dependency>
</dependencies>
</package>
</packages>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…