简体   繁体   English

如何在Maven2中构造自定义类路径

[英]How to construct a custom class path in Maven2

I'm executing an ant task inside my maven pom files to code generation purposes. 我正在我的maven pom文件中执行一个ant任务,以生成代码。 (the code-generation tool is wsdl2java). (代码生成工具是wsdl2java)。 during the process I fork new java process and pass the class path along with wsdl. 在此过程中,我派生了新的Java流程,并将类路径与wsdl一起传递。

this works fine in the unix environment. 这在Unix环境下工作正常。 but windows gives error saying ; 但是Windows给出错误的说法;

CreateProcess error=87, The parameter is incorrect.

this is because I'm passing the parameter maven.dependency.classpath as the classpath of the codegen tool. 这是因为我将参数maven.dependency.classpath传递为代码生成工具的类路径。 I have figured out that if there is a way to construct my custom classpath, using maven, that would solve my problem. 我已经发现,如果有一种使用maven构造自定义类路径的方法,则可以解决我的问题。 (instead of giving a classpath includes all the jars in the maven repo). (不是给出类路径,而是包括Maven回购中的所有jar)。

maven-dependency-pluing:build-path goal seems to be promising, but i can specify the exact jars i want to include in my new classpath. maven-dependency-pluing:build-path目标似乎很有希望,但是我可以指定要包含在新类路径中的确切jar。

  • i have to include the class path variable in a root, pom so that other modules can use it.(lots of them) 我必须在根目录pom中包含类路径变量,以便其他模块可以使用它。
  • I could find a way with maven-dependency-plugin:copy goal. 我可以找到一种方法与maven-dependency-plugin:copy目标。 but that it is a performance hit. 但这是对性能的打击。

appreciate any help. 感谢您的帮助。 thanks in advance. 提前致谢。

I could not find a way to build a classPath using dependency or any other maven plugin. 我找不到使用依赖项或任何其他Maven插件构建classPath的方法。 The only option was to create a custom classPath and use it while java execution. 唯一的选择是创建一个自定义的classPath并在java执行时使用它。

<path id="custom.classpath">
  <pathelement location="location of the jar file"/>
</path>

And you refer the constructed classpath later in the java process execution. 稍后在Java流程执行中引用构造的类路径。

<java className = "org.myClass">
     <classpath refid="custom.classpath"/>
</java>

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM