【问题标题】:Move a config file into etc folder(of Karaf) when a (Maven)bundle is deployed部署 (Maven) 包时,将配置文件移动到 (Karaf) 的 etc 文件夹中
【发布时间】:2014-10-10 07:02:00
【问题描述】:

每当部署捆绑包时,我想将 cfg 文件移动到 karaf 的 etc 文件夹中。 cfg 文件位于 src/main/resource 下。我在 pom 中尝试了以下操作,但它不起作用。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.1</version>
    <executions>
        <execution>
            <phase>deploy</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <tasks>
                    <echo>Using env.test.properties</echo>
                    <copy file="src/main/resources/test.cfg" tofile="${env.KARAF_HOME}/etc/test.cfg"/>
                    </tasks>
                </configuration>
            </execution>
        </executions>
    </plugin>

我该怎么做?

【问题讨论】:

    标签: maven pom.xml apache-karaf


    【解决方案1】:

    其中一个解决方案可能是: - 将您的 test.cfg 文件放在更具体的文件夹中。 (例如:src/main/resources/cfg) - 使用 maven 资源插件

    这是一个基于 maven 阶段 generate-resources 的工作示例(在您的情况下通过部署替换该阶段):

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-resources-plugin</artifactId>
      <executions>
        <execution>
          <id>copy-to-karaf</id>
          <phase>generate-resources</phase>
          <goals>
            <goal>copy-resources</goal>
          </goals>
          <configuration>
            <resources>
              <resource>
                <directory>src/main/resources/cfg</directory>
                <filtering>true</filtering>
              </resource>
            </resources>
            <outputDirectory>D:\apache-karaf-3.0.1\etc\</outputDirectory>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-29
      • 1970-01-01
      • 2016-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      相关资源
      最近更新 更多