简体   繁体   English

Maven:无法将资源复制到远程目录

[英]Maven : Not able to copy resources to remote dir

I am using : 我在用 :

  • openjdk version "11.0.1" 2018-10-16 openjdk版本“ 11.0.1” 2018-10-16
  • Apache Maven 3.6.0 to build my project. Apache Maven 3.6.0构建我的项目。

Expecting 3 resource files to be copied from the server from where I am compiling to the server where to copy the resource file.Expected way: 预计将3个资源文件从我正在编译的服务器复制到要复制资源文件的服务器。预期方式:

  • Copying context.xml to /online/sand/pps/apache-tomcat-9.0.8/webapps/pps/META-INF from local target/classes/env/${current_env}_context.xml 从本地target / classes / env / $ {current_env} _context.xml将context.xml复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/META-INF
  • Copying application.properties to /online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes from local target/classes/env/${current_env}_application.properties 从本地目标/类/env/${current_env}_application.properties将application.properties复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes
  • Copying promote_servers.properties to /online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes from local target/classes/env/${current_env}_promote_servers.properties 从本地target / classes / env / $ {current_env} _promote_servers.properties将promote_servers.properties复制到/online/sand/pps/apache-tomcat-9.0.8/webapps/pps/WEB-INF/classes

Hence I set up profile in pom.xml as : 因此,我在pom.xml中将配置文件设置为:

<profile>
    <id>dev</id>
    <activation/>
    <properties>
        <INSTALL_MACHINE_LIST>dc1uoappptl01.patamoc-us.com</INSTALL_MACHINE_LIST>
        <COPY_MODE>sftp</COPY_MODE>
        <FTP_USERNAME>theusr</FTP_USERNAME>
        <FTP_PASSWORD>pswd</FTP_PASSWORD>
        <project_lib>/online/sand/pps/apache-tomcat-9.0.8/webapps</project_lib>
    </properties>
</profile>

to copy the resources, I have used : 复制资源,我用过:

<plugin>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <phase>install</phase>
            <configuration>
                <target>
                    <copy file="${project.build.directory}/classes/env/${current_env}_context.xml"
                          tofile="${project_lib}/pps/META-INF/context.xml"
                          overwrite="true"/>
                    <copy file="${project.build.directory}/classes/env/${current_env}_application.properties"
                          tofile="${project_lib}/pps/WEB-INF/classes/application.properties"
                          overwrite="true"/>
                    <copy file="${project.build.directory}/classes/env/${current_env}_promote_servers.properties"
                          tofile="${project_lib}/pps/WEB-INF/classes/promote_servers.properties"
                          overwrite="true"/>
                </target>

            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>

my .war file is being stfp to the right location. 我的.war文件被stfp定位到正确的位置。 However, the resource files are not. 但是,资源文件不是。 I have checked directory permission is right in the remote dir where the files should be copied. 我已经检查了目录权限是否在应该复制文件的远程目录中。 Log file for the maven installation says that the resources have been copied to the directories mentioned above and installation is a success. maven安装的日志文件显示资源已复制到上述目录,安装成功。

Any idea on what I am missing? 对我想念的东西有任何想法吗? Should I use a different plug-in for resource copy part? 我应该为资源复制部分使用其他插件吗?

my first guess is that the lifecycle phase of the copying of your file is too late (or just after the sftp of your actual resources) but to prove that you should post also the goal to copy the sftp. 我的第一个猜测是,复制文件的生命周期阶段为时已晚(或紧随实际资源的sftp之后),但为了证明您还应该发布复制sftp的目标。

you can try to simply change the 您可以尝试简单地更改

<executions>
        <execution>
            <phase>install</phase>

to

<executions>
        <execution>
            <phase>package</phase>

so its in an early stage... see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html 所以它处于早期阶段...请参阅https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM