使用Maven(比配置文件更好的东西)为多个Java体系结构构建工件吗? [英] Building artifacts for multiple java architectures using Maven (anything better than profiles)?

查看:60
本文介绍了使用Maven(比配置文件更好的东西)为多个Java体系结构构建工件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经阅读了我能找到的每个帖子和问题,我为找到一种比仅使用配置文件更好的方法而感到困惑的方法.

Having read about every posting and question that I can find, I'm stumped on finding a better way than just using profiles of doing the following.

我需要采用相同的模块集,并针对非常不同的体系结构(J2ME与J2SE)编译它们,它们对某些库需要不同的依赖关系,并且在编译时需要不同的源/目标/调试设置.

I need to take the same set of modules, and compile them for vastly different architectures (J2ME vs. J2SE), they need different dependencies for some libraries, and they need different source/target/debug settings at compilation time.

使用配置文件和分类器,我可以通过运行一个配置文件,清理并使用另一个配置文件运行构建来实现.分类器对结果进行排序.但是,如果您只是更改配置文件并重建,它就不会自己清理,它需要针对超级pom多次运行maven,并且它不允许您同时启用多个配置文件(以及结果)搞砸时很难看.)

Using profiles and classifiers, I can do this by running with one profile, cleaning, and running a build with the other profile. The classifiers sort out the results. However, if you just change profiles and rebuild, it won't clean on it's own, it requires multiple running of maven against the super-pom, and it won't allow you to enable multiple profiles at the same time (and the resultant mess when you do is pretty ugly).

我可以使用附加的工件并强迫编译和jar步骤多次运行来做些什么吗?

Could I do something using attached artifacts and forcing the compile and jar steps to run multiple times?

javac选项确实起了很大作用:(将配置文件用于依赖项不会引起任何问题)

The javac options are really the kicker: (using profiles for the dependencies doesn't cause any issues)

对于J2ME:
来源= 1.4
目标= 1.4
-g:source

for J2ME:
source=1.4
target=1.4
-g:source

用于J2ME调试
来源= 1.4
target = 1.4

for J2ME debugging
source=1.4
target=1.4

对于J2SE
来源= 1.5
target = 1.5

for J2SE
source=1.5
target=1.5

推荐答案

您能否明确调用编译器插件

Could you explicitly invoke the compiler plugin Maven Compiler Plugin and then define multiple executions. Some thing like

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <executions>
        <execution>
          <id>compile1</id>
          <phase>generate-resources</phase>
          <goals>
              <goal>compile</goal>
          </goals>
          <configuration>
                <verbose>true</verbose>
                <fork>true</fork>
                <executable><!-- path-to-javac --></executable>
                <compilerVersion>1.3</compilerVersion>
            </configuration>
       </execution>
       <execution>
          <id>compile1</id>
          <phase>generate-resources</phase>
          <goals>
              <goal>compile</goal>
          </goals>
          <configuration>
                <verbose>true</verbose>
                <fork>true</fork>
                <executable><!-- path-to-javac --></executable>
                <compilerVersion>1.3</compilerVersion>
            </configuration>
       </execution>
   </executions>
  </plugin>

这篇关于使用Maven(比配置文件更好的东西)为多个Java体系结构构建工件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆