蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

运行 Maven 演进时间线、核心功能项与构建工具选型矩阵离线核验

PYTHONWindows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。explore-intro.py
explore-intro.py110 行
"""Offline Maven introduction, history & build-tool comparison verifier for Ch02 (intro)."""
import json

VERSION = "CPython 3.12.14 offline Maven POM/lifecycle/dependency verifier (mvn CLI absent)"


def check(name, summary, expected, actual):
    return {
        "name": name,
        "summary": summary,
        "expected": expected,
        "actual": actual,
        "passed": actual == expected,
    }


def main():
    cases = []

    # Case 1: Two core build problems & historical milestones
    milestones = [
        (2002, "Jason van Zyl created Maven to supersede manual Ant scripts"),
        (2004, "Maven 1.0 released"),
        (2005, "Maven 2.0 introduced POM and transitive dependency management"),
        (2010, "Maven 3.0 improved performance and plugin APIs"),
    ]
    years = [y for y, _ in milestones]
    cases.append(
        check(
            "maven_core_problems_and_timeline",
            "Verify the 2 build problems Maven solves and chronological 2002-2010 release milestones",
            {
                "problems_solved": ["how_software_is_built", "software_dependencies"],
                "years_sorted": [2002, 2004, 2005, 2010],
                "is_monotonic": True,
            },
            {
                "problems_solved": ["how_software_is_built", "software_dependencies"],
                "years_sorted": years,
                "is_monotonic": years == sorted(years),
            },
        )
    )

    # Case 2: Core features & standard lifecycle stages
    core_features = {
        "artifact_ext": ".jar",
        "standard_phases": ["clean", "compile", "test", "package"],
        "default_archetype": "maven-archetype-quickstart",
        "compiler_plugin": "maven-compiler-plugin",
        "multi_module": True,
    }
    cases.append(
        check(
            "maven_core_features_and_lifecycle",
            "Verify Maven core features (.jar dependency mgmt, clean/compile/test/package, quickstart archetype, compiler plugin)",
            {
                "artifact_ext": ".jar",
                "standard_phases": ["clean", "compile", "test", "package"],
                "default_archetype": "maven-archetype-quickstart",
                "compiler_plugin": "maven-compiler-plugin",
                "multi_module": True,
            },
            core_features,
        )
    )

    # Case 3: Maven vs Gradle vs Ant comparison matrix
    tools = {
        "Maven": {"config": "XML (pom.xml)", "style": "convention", "dep_mgmt": "built-in"},
        "Gradle": {"config": "Groovy/Kotlin DSL", "style": "flexible_dsl", "dep_mgmt": "built-in"},
        "Ant": {"config": "XML (build.xml)", "style": "imperative_manual", "dep_mgmt": "manual_or_ivy"},
    }
    cases.append(
        check(
            "build_tool_comparison_matrix",
            "Verify Maven vs Gradle vs Ant configuration format, build paradigm, and Ant build.xml contrast",
            {
                "tools": ["Ant", "Gradle", "Maven"],
                "ant_script": "XML (build.xml)",
                "maven_config": "XML (pom.xml)",
                "gradle_dsl": "Groovy/Kotlin DSL",
            },
            {
                "tools": sorted(tools.keys()),
                "ant_script": tools["Ant"]["config"],
                "maven_config": tools["Maven"]["config"],
                "gradle_dsl": tools["Gradle"]["config"],
            },
        )
    )

    # Case 4: Cross-platform JVM execution & IDE ecosystem support
    os_targets = ["Windows", "Linux", "macOS"]
    ides = ["Eclipse", "IntelliJ IDEA", "VS Code"]
    cases.append(
        check(
            "ide_and_cross_platform_support",
            "Verify JVM cross-platform execution across 3 OS families and native support in major IDEs",
            {"os_count": 3, "ide_count": 3, "jvm_based": True},
            {"os_count": len(os_targets), "ide_count": len(ides), "jvm_based": True},
        )
    )

    print(json.dumps({"version": VERSION, "cases": cases}, ensure_ascii=False, indent=2))


if __name__ == "__main__":
    main()
本例需在 Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。

入口文件:projects/maven-intro-lab/explore-intro.py

本地运行步骤快速上手
  1. 点击上方“保存源码”保存为 explore-intro.py,或下载右侧课程工程包。
  2. 确认本地已准备 Windows x64、CPython 3.12.14、Playwright 与本地浏览器/标准库。。
  3. 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载

下载课程关联工程包:Maven

课程关联工程包(登记关联25章) · 含当前章节或实例 · mbskycom202612a2175.zip

下载课程关联工程包:Maven

课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a2187.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习