Building artifacts for multiple java architectures using Maven (anything better than profiles)?

流过昼夜 提交于 2019-12-23 17:26:25

问题


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.

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.

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).

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

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

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

for J2ME debugging
source=1.4
target=1.4

for J2SE
source=1.5
target=1.5


回答1:


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>


来源:https://stackoverflow.com/questions/5162009/building-artifacts-for-multiple-java-architectures-using-maven-anything-better

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!