NutzCN Logo
问答 关于 maven-plugin 开发,任何正确得到 MavenProject 的所有依赖(jar)
发布于 443天前 作者 limingwei 654 次浏览 复制 上一个帖子 下一个帖子
标签:

得到项目的所有依赖,是应该用 org.apache.maven.project.MavenProject.getArtifacts() 么?
如果遇到 workspace 里有的项目,这个方法返回的 Artifact 的 file 就是个 target\classes 文件夹,而不是 .jar 文件
咋整

12 回复

如何正确得到 MavenProject 的所有依赖

workspace?eclipse下面开发的??

哦,eclipse的骚操作,我都是写好然后install再跑

![avatar][base64strdata:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUUAAABkCAYAAAAR8yJ6AAAP5UlEQVR4nO2dT2gj1x3HfwmladpAdSiFvWQ3WoOL6aGoi44JxZGd4EBxii7pZdhDsA41JrBQ5dBlTyroUOEErF4W0dBcVKJDY4jlmjSXHsRWh1BMBWt3lxwCpQcF0kNP6fvNP70ZzXt6M9JII+n7AYE143nvzXtPX/1+M6P3fWY4HH5DAAAAbJ5ddAMAACBLQBQBAEACoggAABIQRQAAkIAoAgCABEQRAAAkIIoAACDxLdWO7e3t2IVdXFxM1RgwHzC2AKhRiiLz6NEj44Lu3LkzRTOu6WSnQNUekdUeUqMkv28TlU9pb9ig0vUJ7RQ6tN/vUiU/RXVgjmMbg/MjytU3qd+t0HoM7zkd5eq0ifmcKdJPn1nIcjnK+a8dOrkO/8sBVbfaNByyII6/B1mDP8zj42iP9c4JhTdnD27/aE4enS+6PSBLpCuK/M1vR3ZDW+DsV3+fOoXgRLwa9Ki4eVv53idfoe4Q36rz4IsvvqDXX3+dzs7OFt2UCDiTSCpmLIhlorY3J/u0WT+i5dPFafoA6NCmz9MhJl+5ZafDARFjYWsPKFc+clLi9BoAEsKC+Pbbb9Pt27fp5ZdfXnRzZsv1Y7os1qjpT7w8VbqNRbYIZIz0IsXzU2qJyXcYpXqlPbLokh5fczCZI6Gd1KsWRCpzREeh94EvQjsV97a5KdzJkZ8G7QTyuWCKtDOW64EoZEGs1+v0/PPPJyzJi2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Pn51WcXc1PmAmqOo07hQ9oLmsppEB5w+L+gxIQCAEcaiePejp/T06ejVeovop/c/o6cf3aVbCSv3hDETgsjm9r0qHUsX/M6P3BT5akA9IZhNN8y7PutQT3mcSLXrrVEhQlBP7H1sNtWnWrFHg6t0TwUAkJyFu/ktXAx9REQnIsAdkT7n3C1We0gNe9ch1eoFkVk7iXXRsqRIURzXtihXzon0295LtZpF5GXq+QptHPPNF79QGuKiIgCZRWlHwIvMZmk9RSwyCwCYByv8Mz8AAIgPRBEAACQgigAAIAFRBAAACYgiAABIQBQBAEBC+5wirEUBAOuG8jlFAABYR5A+AwCABEQRAAAk/g+a+JJIB9CHtQAAAABJRU5ErkJggg==]

没有
而且我也不确定
用 MavenProject.getArtifacts方法 得到项目依赖的所有jar,这个方式是否正确
但效果是能拿到
除了 workspace artifact

写nutzboot maven plugin的时候没遇上这个问题,可能是因为继承了shade?

shade 好像不会有这回事儿
因为 shade 打包时,需要的就是 class 文件,即使拿到的依赖是jar,也要给解压掉

用 org.apache.maven.execution.MavenSession.getLocalRepository().find(org.apache.maven.artifact.Artifact) 可以从本地库拿到
不确定是否正确

添加回复
请先登陆
回到顶部