聚合器生成中的Maven Enforcer BandDistributionManagement规则

聚合器生成中的Maven Enforcer BandDistributionManagement规则,maven,maven-3,maven-enforcer-plugin,Maven,Maven 3,Maven Enforcer Plugin,给定公司pom和项目结构: child (inherits from company-pom) +-- child2 (inherits from child) 当我在child中使用company pom运行mvn install时,它在 [INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-distribution) @ child --- [DEBUG] Configuring mojo org.apache.mave

给定公司pom和项目结构:

   child (inherits from company-pom)
     +-- child2 (inherits from child)
当我在child中使用company pom运行
mvn install
时,它在

[INFO] --- maven-enforcer-plugin:1.4:enforce (enforce-distribution) @ child ---
[DEBUG] Configuring mojo org.apache.maven.plugins:maven-enforcer-plugin:1.4:enforce from plugin realm ClassRealm[plugin>org.apache.maven.plugins:maven-enforcer-plugin:1.4, parent: sun.misc.Launcher$AppClassLoader@234f79cb]
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-enforcer-plugin:1.4:enforce' with basic configurator -->
[DEBUG]   (s) fail = true
[DEBUG]   (s) failFast = false
[DEBUG]   (f) ignoreCache = false
[DEBUG]   (f) mojoExecution = org.apache.maven.plugins:maven-enforcer-plugin:1.4:enforce {execution: enforce-distribution}
[DEBUG]   (s) project = MavenProject: com.acme.maven:child:1-SNAPSHOT @ /home/egnyte/test/child/pom.xml
[DEBUG]   (s) ignoreParent = true
[DEBUG]   (s) rules = [org.apache.maven.plugins.enforcer.BanDistributionManagement@3020cc2d]
[DEBUG]   (s) session = org.apache.maven.execution.MavenSession@4a0d851e
[DEBUG]   (s) skip = false
[DEBUG] -- end configuration --
[DEBUG] Executing rule: org.apache.maven.plugins.enforcer.BanDistributionManagement
[DEBUG] distributionManagement: org.apache.maven.model.DistributionManagement@393cb70a
[DEBUG] Adding failure due to exception
org.apache.maven.enforcer.rule.api.EnforcerRuleException: You have defined a repository in distributionManagement.
        at org.apache.maven.plugins.enforcer.utils.DistributionManagementCheck.execute(DistributionManagementCheck.java:46)
        at org.apache.maven.plugins.enforcer.BanDistributionManagement.execute(BanDistributionManagement.java:87)
        at org.apache.maven.plugins.enforcer.EnforceMojo.execute(EnforceMojo.java:150)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BanDistributionManagement failed with message:
You have defined a repository in distributionManagement.
无论我做什么,这条规则似乎在多模块项目的第一个子项目中失败了

尝试:

  • 使子组件成为公司pom的一个模块(并从公司pom目录运行
    mvn install

  • 显式地将
    ignoreParent
    设置为
    true
    false

用于测试此项的文件:./pom.xml


4.0.0
com.acme.maven
超级聚甲醛
1-快照
聚甲醛
释放
https://mvnrepo.acme.com/content/repositories/releases/
maven enforcer插件
1.4
强制分配
执行
./child/pom.xml


4.0.0
com.acme.maven
超级聚甲醛
1-快照
小孩
聚甲醛
孩子2
child 2./child/child2/pom.xml


4.0.0
com.acme.maven
小孩
1-快照
孩子2

你从哪里打电话给maven的?从根开始?此外,我假设您没有将其中一个异常设置为true,比如
allowRepository
?因为它们都默认设置为false。@khmarbaise re。“从哪里打电话来的”请参见编辑。例外-为什么我需要一个?要么文档是完全误导性的,要么我不想有任何例外(我只想在公司pom中使用distributionManagement元素),抱歉,如果您不想回答我帮不上忙的问题……什么?我只是回答了你的问题,更不用说制作一个演示项目了。很抱歉,你没有阅读文档,也没有阅读我的评论,没有回答我的问题。摘录自文档:
上述配置将阻止在pom文件中声明distributionManagement,但在父文件中除外
。这引用了文档中的示例,该示例正是您复制的。但是您没有尝试更改配置以查看发生了什么。正如我已经提到的,您应该添加
allowRepository
,并将其设置为true。