【问题标题】:idlj-maven-plugin and package translationidlj-maven-plugin 和包翻译
【发布时间】:2012-08-22 08:31:48
【问题描述】:

我正在尝试使用 idlj-maven-plugin 在 Maven 项目中包含一个 Corba .idl 文件。 .idl 文件指定了某个模块,比如

module Tester
{
  interface Test {
    void sayHello();
  }
}

我希望生成的类属于包com.mycompany.tester。我试过使用

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>idlj-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
            <debug>true</debug>
            <compiler>jacorb</compiler>
            <sourceDirectory>../../idl</sourceDirectory>
            <source>
                <packageTranslations>
                    <packageTranslation>
                        <type>Tester</type>
                        <package>com.mycompany.tester</package>
                    </packageTranslation>
                </packageTranslations>
            </source>
        </configuration>
      </plugin>

但它似乎完全没有效果。我也试过把idlj当作&lt;compiler&gt;,或者用

                <additionalArguments>
                    <additionalArgument>
                        -i2jpackage Tester:com.mycompany.tester
                    </additionalArgument>
                </additionalArguments>

但似乎没有任何效果。

有什么想法吗?

【问题讨论】:

    标签: java maven corba idl


    【解决方案1】:

    我已经设法使一切都以这种方式工作:

       <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>idlj-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
              <execution>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
                <debug>true</debug>
                <compiler>jacorb</compiler>
                <sourceDirectory>../../idl</sourceDirectory>
                <sources>
                    <source>
                        <additionalArguments>
                            <list>-i2jpackage</list>
                            <list>Tester:com.mycompany.tester</list>
                        </additionalArguments>
                    </source>
                </sources>
            </configuration>
          </plugin>
    

    当使用&lt;compiler&gt;idlj&lt;/compiler&gt; 时,我改为使用&lt;additionalArguments&gt;

    <additionalArguments>
        <list>-pkgTranslate</list>
        <list>Tester</list>
        <list>com.mycompany.tester</list>
    </additionalArguments>
    

    【讨论】:

      【解决方案2】:

      idlj命令使用起来更方便

      ====  your tester.idl  ====
      
      module tester
      {
          interface Test {
              void sayHello();
          }
      }
      
      ===========================
      

      您可以使用带有选项-pkgPrefix的idlj来生成java文件到某个包,如下所示

      idlj -pkgPrefix tester com.mycompany -fall tester.idl
      

      【讨论】:

        【解决方案3】:

        虽然 idlj-maven-plugin 使用页面中的示例另有说明,但您必须将源选项包装在 sources 元素中:

        <configuration>
            <compiler>jacorb</compiler>
            <sources>
                <source>
                    <packagePrefix>com.acme</packagePrefix>
                </source>
            </sources>
        </configuration>
        

        【讨论】:

          猜你喜欢
          • 2016-02-19
          • 2014-05-14
          • 1970-01-01
          • 1970-01-01
          • 2016-11-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多