Наложите BIRT runtime на правильные боевые локации

StackOverflow https://stackoverflow.com/questions/1335283

  •  20-09-2019
  •  | 
  •  

Вопрос

Я пытаюсь заставить 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

Редактировать:

Причина указанных выше местоположений заключается в том, что они соответствуют местоположениям, указанным в 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));
Это было полезно?

Решение

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

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

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

Следующая конфигурация будет делать именно это (я еще не тестировал это, поэтому приношу извинения, если есть какие-либо упущения, смотрите документацию для получения точных деталей).Обратите внимание, что выполнение находится в одной и той же фазе, но до тех пор, пока dependency-plugin настроен до antrun-plugin, он будет выполняться первым.Обратите внимание, что prepare-package является новым для 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>

Другие советы

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

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

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

в основном то же самое, что и моя первоначальная попытка создания плагина war.Я ничего не вижу в документах для depedency-распакуйте, чтобы помочь.Я попробую еще раз 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>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top