jaxb episodic compilation with maven

2019-07-23 14:35发布

I am trying to execute the maven-jaxb2-plugin-sample-episode-0.7.4 (explained here and with a download available) to try separate schema compilation. Despite it compiles the first schema (A), it fails in the second one (B) because it is not able to resolve the artifact maven-jaxb2-plugin-sample-episode-a-maven:jar:0.7.4.

I execute mvn assembly:assembly from the command line (windows) and this is the error I get:

...
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven JAXB 2.x Plugin Sample [episode-b|maven]
[INFO] ------------------------------------------------------------------------
[INFO] [jaxb2:generate {execution: default}]
Downloading: http://repo1.maven.org/maven2/org/jvnet/jaxb2/maven2/maven-jaxb2-pl
ugin-sample-episode-a-maven/0.7.4/maven-jaxb2-plugin-sample-episode-a-maven-0.7.
4.jar
[INFO] Unable to find resource 'org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-sample
-episode-a-maven:jar:0.7.4' in repository central (http://repo1.maven.org/maven2
)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not resolve the artifact.

Embedded error: Missing:
----------
1) org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-sample-episode-a-maven:jar:0.7.4

  Try downloading the file manually from the project website.

  Then, install it using the command:
      mvn install:install-file -DgroupId=org.jvnet.jaxb2.maven2 -DartifactId=mav
en-jaxb2-plugin-sample-episode-a-maven -Dversion=0.7.4 -Dpackaging=jar -Dfile=/p
ath/to/file

  Alternatively, if you host your own repository you can deploy the file there:

      mvn deploy:deploy-file -DgroupId=org.jvnet.jaxb2.maven2 -DartifactId=maven
-jaxb2-plugin-sample-episode-a-maven -Dversion=0.7.4 -Dpackaging=jar -Dfile=/pat
h/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency:
        1) org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-ample-episode-b-maven:jar:0
.7.4
        2) org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-sample-episode-a-maven:jar:
0.7.4

----------
1 required artifact is missing.

for artifact:
  org.jvnet.jaxb2.maven2:maven-jaxb2-plugin-ample-episode-b-maven:jar:0.7.4

from the specified remote repositories:
  central (http://repo1.maven.org/maven2)


[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Wed Dec 22 16:31:29 CET 2010
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------

The example should work as it is so, what am I doing wrong ? In the real scenario I have more than 10 schemas that have to be compiled as different episodes, so I need the proccess to be automatic (i.e no need to execute "mvn something" for each individual artifact)

1条回答
做个烂人
2楼-- · 2019-07-23 15:02

The module maven-jaxb2-plugin-ample-episode-b-maven depends on maven-jaxb2-plugin-ample-episode-a-maven.

When mvn assembly:assembly is run from the parent folder (which contains the two modules), it builds the jar for maven-jaxb2-plugin-ample-episode-a-maven, but does not install it in your local repository.

When it then tries to build maven-jaxb2-plugin-ample-episode-b-maven, it looks for the dependency (maven-jaxb2-plugin-ample-episode-a-maven) and fails to find it in the local repository. Thus the error.

The question is, why would you want to run mvn assembly:assembly, which is used to create a binary distribution? There are no assembly descriptors in either module.

mvn install works fine and build both the modules successfully.

查看更多
登录 后发表回答