Free Pascal 能否受益于 Apache Maven 之类的东西?
Apache Maven是Java开源生态圈中非常流行的构建和依赖管理工具。我做了一些测试,看看它是否可以处理编译的 Free Pascal / Delphi 单元,并发现它很容易实现。因此,可以
- 在公共 Maven 存储库中发布为 Free Pascal(或 Delphi)预编译的开源库,
- 包括此存储库中的元数据,其中包含依赖项信息,
- 在命令行上使用 Maven 从公共存储库下载开源库,并且自动解析所有依赖项
- 本地存储库作为代理,可用于缓存常用的二进制文件
- 自动校验和生成和验证(由 Maven 提供)将降低下载损坏的二进制文件源代码的风险
- ,甚至可以随二进制文件一起提供文档
- 文件可以提供或不提供调试信息
- 持续集成服务器,例如 Hudson、TeamCity 或 CruiseControl每当更改已提交到源代码控制系统时就构建项目,并通知开发人员有关构建错误的
依赖关系管理方式对于使用许多具有复杂依赖关系的第三方库的开源项目非常有益。它将避免因使用错误版本而引起的典型冲突。
对于开发人员来说,编辑和构建项目的工作流程将减少到最低限度:
- 从内部版本控制系统检出项目源
- 代码编辑源文件
- 运行
mvn package
以自动下载所有必需的第三方方库(预编译单元)(如果尚未在工作站的本地存储库中) - 编译并运行
项目文件夹中所需的 Apache Maven 的唯一附加文件是包含项目信息的 POM.XML 文件。
编辑:虽然 Maven 可用于某些必需的任务,但在本机 Free Pascal 中实现像 Maven 这样的解决方案将具有一些优点:不需要 Java SDK、支持 Free Pascal 可用的所有开发平台、在 Pascal 中进行维护和插件开发。
使用类似 Maven 的工具仅对开源项目没有帮助 - 商业项目也可以以相同的方式访问和使用公共 Maven 存储库中的工件。
Maven 功能列于 http://maven.apache.org/maven-features.html
更新:
一个用例可能是 Lazarus 的构建,其中 Maven 将下载所有必需的库并使用必要的构建路径参数调用编译器。较低级别的依赖项的更改将自动传播到父构建。
可能的好处:
- 减少建立新工作所需的时间 站,无需手动安装 需要第三方库,
- 减少因错误库引起的错误 版本,版本检测 冲突(例如,如果两个 库依赖于不同的 第三个库的版本)
- 内部创建的工件 可以添加到本地maven 存储库并在之间共享 开发商和项目,中央 所有工件的存储 元数据
- 构建是可重现的,只需 使用相同的源和项目 元数据文件(pom.xml)
- 可以减少开发时间 提高项目稳定性
更新 #2:FPMake
Free Pascal 的 FPMake 构建系统似乎作为一个具有很大潜力的工具,在许多细节上它与 Maven 非常相似:
- FPMake 是一个基于 pascal 的构建系统,为 FPC 开发并随 FPC 一起分发。
- FPMake 通过定义一些限制(如标准目录)来标准化构建,
- 命令
fppkg < packagename>
将在数据库中查找包,将其解压缩,然后编译 fpmake.pp 并运行它, - 它具有标准构建目标(clean、build、install,...),
- 它可以创建一个“清单”适合导入到存储库的文件(例如
mvn deploy
或mvn install
),清单是一个 XML 文件,看起来与 Maven 中的 pom.xml 非常相似:
FPMake清单文件:
<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>[email protected]</email>
<description>this is the package description</description>
<dependencies>
<dependency>
<package packagename="rtl"/>
</dependency>
</dependencies>
</package>
</packages>
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
ormvn 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>[email protected]</email>
<description>this is the package description</description>
<dependencies>
<dependency>
<package packagename="rtl"/>
</dependency>
</dependencies>
</package>
</packages>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Freepascal 一直致力于以 apt-get 和 freebsd ports 风格交叉的方式开发自己的软件包系统。 (自动下载源/构建/安装),称为 fppkg。
然而工作却陷入停滞。瓶颈在于投入时间的人,而不是想要选择工具的人。
就 Maven 而言,我不喜欢需要安装大量外部运行时的辅助工具。对于大型应用程序(例如 Open Office)来说这可能没问题,但对于实用程序则不然。
我还更喜欢专为 FPC 实际情况和工作流程设计的工具。
文档工具、构建工具、下载系统、测试套件系统都已经存在,只需要一个人投入大量时间即可实现。
在 FPC 等项目中引入新技术时的一些典型问题,以及为什么它倾向于制作自己的工具:
显然
这一切都导致了有效的实践,即在 Pascal 中拥有工具并使用最少的脚本工作效果最好。使用的一些工具:
如果有人真的认真对待 Maven,我通常会问他:
请记住,在公司中,您只需踢掉负责应用程序服务器的人员即可。但在非正式环境中,这要困难得多,尤其是长期而言,因为人们的生活、职业和花在项目上的时间各不相同。
Freepascal has been working on a package system of its own in a cross between apt-get and freebsd ports style. (download source/build/install automatically), called fppkg.
However work has stalled. People investing time are the bottleneck, not people wanting to choose tools.
As far as Maven goes, I don't like auxilary tools that need installation of huge external runtimes. It might be fine for a big major app (like Open Office), but not for an util.
I also prefer a tool that is designed to the FPC reality and workflow.
Documentation tools, build tools, download systems, testsuite systems are already all there, it just need a person that dedicates a lot of time into it to make it happen.
Some typical problems when introducing a new technology in a project as FPC, and why it has a tendency to make its own tools:
This all leads to the effective practice that own tools in Pascal with minimal scripting work best. Some tools used:
If somebody was really serious about Maven, I usually would ask him:
Keep in mind that in a company you just kick the person responsible for the application server. But in an informal environment this is way harder, specially long term, since people's lives, occupations and time spent on the project vary.
听起来是一个有趣的计划,但 Delphi 社区(我想 FPC 更是如此!)将库作为源代码的价值远远超过预编译库。普遍的共识是,任何使用纯二进制库的人都是傻瓜,原因有两个:你无法修复在其中发现的任何错误,并且编译器的更改将破坏兼容性。
Sounds like an interesting plan, but the Delphi community (and FPC even more so, I'd imagine!) values libraries as source far more than precompiled libraries. The general consensus is that anyone who uses a binary-only library is a fool, for two reasons: You can't fix any bugs you find in it, and compiler changes will break compatibility.