开发者

maven classpath generation for deployment and test

开发者 https://www.devze.com 2023-01-08 01:02 出处:网络
I have a module that is used by creating a custom class loader. The class loader should therefore be created with the path to the module and also all dependencies.

I have a module that is used by creating a custom class loader. The class loader should therefore be created with the path to the module and also all dependencies.

I'm looking for a way to make it productive to work with this mechanism in both dev and production environments.

I thought the build can generate two files listing all dependency paths. A 'dev' file and 'production' file (then in the code I'd choose the right file based on some system property):

  • dev: dependencies should be paths to thirdparty jars in the local maven repository or 'target\classes' for other modules (which will allow to compile with the IDE and not need a full build for each change)
  • p开发者_如何学Goroduction: all jars should be copied to a 'lib' folder and the dependencies should list them (without full path). Alternatively, create an uber jar, and then the (?)

So I'm looking for pointers to plugins & pom snippets to help me with this.


Some hints:

  • For the dev part, the Maven Dependency Plugin and its dependency:build-classpath can help (and supports writing the output to a file). Another option would be to use the Maven AntRun plugin, it has access to the Maven runtime classpath, it should be easy to write the property to a file.

  • For the prod part, I assume you'll use the Maven Assembly Plugin or the Shade Plugin or another equivalent and I wonder if you couldn't generate a classpath entry in the MANIFEST.MF and rely on it.

0

精彩评论

暂无评论...
验证码 换一张
取 消