Наложение времени выполнения BIRT на правильные локации WAR - PullRequest
3 голосов
/ 26 августа 2009

Я пытаюсь заставить Maven собрать WAR-файл со средой выполнения BIRT в полезном месте в WAR-файле.

Среда выполнения BIRT находится в файле pom.xml как

<dependency>
  <groupId>org.eclipse.birt</groupId>
  <artifactId>report-engine</artifactId>
  <version>2.3.2</version>
  <type>zip</type>
  <scope>runtime</scope>
</dependency>

Желаемый результат наложения это что-то вроде

ReportEngine/lib/*           -> WEB-INF/lib 
ReportEngine/configuration/* -> WEB-INF/platform/configuration 
ReportEngine/plugins/*       -> WEB-INF/platform/plugins 

Моя конфигурация наложения выглядит как

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <overlays>
      <overlay>
        <groupId>org.eclipse.birt</groupId>
        <artifactId>report-engine</artifactId>
        <type>zip</type>
        <includes>
          <include>ReportEngine/lib/*</include>
        </includes>
        <targetPath>WEB-INF/lib</targetPath>
      </overlay>
      <overlay>
        <groupId>org.eclipse.birt</groupId>
        <artifactId>report-engine</artifactId>
        <type>zip</type>
        <includes>
          <include>ReportEngine/configuration/*</include>
          <include>ReportEngine/plugins/*</include>
        </includes>
        <targetPath>WEB-INF/platform</targetPath>
      </overlay>
    </overlays>
  </configuration>
</plugin>

Конечно, при запуске mvn war:exploded Я вижу

ReportEngine/lib/*           -> WEB-INF/lib/ReportEngine/lib/ 
ReportEngine/configuration/* -> WEB-INF/platform/configuration/ReportEngine/lib/ 
ReportEngine/plugins/*       -> WEB-INF/platform/plugins/ReportEngine/lib/

Это относится, такая же проблема, нет ответа http://www.coderanch.com/t/447258/Ant-Maven-Other-Build-Tools/Maven-war-dependencies-moving-files

Бонусные баллы за указание на то, как я могу немного привести в порядок эту ситуацию, заставив все это работать изнутри WEB-INF/birt-runtime

Edit:

Причина расположения, указанного выше, заключается в том, что они совпадают с указанными в http://wiki.eclipse.org/Servlet_Example_%28BIRT%29_2.1, и когда я провожусь с установкой Tomcat, чтобы имитировать это, кажется, все работает. Было бы идеально, если бы я мог просто наложить zip-файл в WEB-INF / birt-runtime, а затем соответствующим образом настроить конфигурацию двигателя, но я пока не нашел, чтобы это работало.

Например:

engineConfig = new EngineConfig();
engineConfig.setEngineHome("WEB-INF/birt-runtime");
engineConfig.setPlatformContext(new PlatformServletContext(servletContext));

Ответы [ 2 ]

1 голос
/ 26 августа 2009

Обновление: перечитывая вопрос, я понимаю, что пропустил подкаталоги из своего тестового проекта, так что, конечно, он работал для меня, извините за это.

Насколько я знаю, в наложении войны или плагине зависимостей не существует механизма для распаковки вложенных папок с артефактами в каталог и исключения родительских элементов пути, оба из них предоставят вам полный относительный путь.

Однако вы можете использовать цель распаковки, чтобы распаковать архив во временную папку, а затем использовать antrun-plugin , чтобы скопировать необходимые подпапки в их последние места отдыха.

Следующая конфигурация будет делать именно это (я еще не проверял это, поэтому извиняюсь, если есть какие-либо упущения, см. Документацию для точных деталей). Обратите внимание, что выполнение находится в той же фазе, но пока плагин зависимостей настроен до того, как плагин antrun будет выполняться первым. Обратите внимание, что подготовительный пакет является новым для Maven 2.1, если вы используете более старую версию, вам нужно будет использовать другую фазу.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <executions>
    <execution>
      <id>unpack-lib</id>
      <phase>prepare-package</phase>
      <goals>
        <goal>unpack</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>jar</type>
            <overWrite>false</overWrite>
          </artifactItem>
        </artifactItems>
        <!--unpack all three folders to the temporary location-->
        <includes>ReportEngine/lib/*,ReportEngine/configuration/*,ReportEngine/plugins/*</includes>
        <outputDirectory>${project.build.directory}/temp-unpack</outputDirectory>
        <overWriteReleases>false</overWriteReleases>
      </configuration>
    </execution>
  </executions>
</plugin>
  <plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
      <execution>
        <phase>prepare-package</phase>
        <configuration>
          <tasks>
            <!--now copy the configuration and plugin sub-folders to WEB-INf/platform-->
            <copy todir="${project.build.directory}/WEB-INF/platform">
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/configuration"/>
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/plugins"/>
            </copy>
            <!--copy the lib sub-folder to WEB-INf/lib-->
            <copy todir="${project.build.directory}/WEB-INF/lib">
              <fileset dir="${project.build.directory}/temp-unpack/ReportEngine/lib"/>
            </copy>
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
0 голосов
/ 26 августа 2009

На самом деле не отвечаю на мой вопрос, отвечая богатому продавцу выше :)

Пытаясь заставить его работать с mvn dependency:unpack, в документах говорится, что он должен быть удален из узла выполнения. Не уверен, что это является причиной результата, но это заканчивается

WEB-INF/lib/ReportEngine/lib
WEB-INF/platform/ReportEngine/configuration
WEB-INF/platform/ReportEngine/plugins

в основном так же, как моя первоначальная попытка плагинов войны. Я не вижу в документах ничего, что могло бы помочь распаковке зависимостей. Попробую еще раз tmrw.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>

      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>zip</type>
            <overWrite>false</overWrite>
            <!--may not be needed, need to check-->
            <outputDirectory>${project.build.directory}/WEB-INF/lib</outputDirectory>
            <includes>ReportEngine/lib/*</includes>
          </artifactItem>

          <artifactItem>
            <groupId>org.eclipse.birt</groupId>
            <artifactId>report-engine</artifactId>
            <version>2.3.2</version>
            <type>zip</type>
            <overWrite>false</overWrite>
            <!--may not be needed, need to check-->
            <outputDirectory>${project.build.directory}/WEB-INF/platform</outputDirectory>
            <includes>ReportEngine/configuration/*,ReportEngine/plugins/*</includes>
          </artifactItem>
        </artifactItems>
      </configuration>
</plugin>
...