如何在这个Maven插件中设置路径?
我是Maven插件的新手,我需要让这个插件运行sencha cmd工具来缩小我们的JavaScript应用程序,作为日常构建过程的一部分 当前可执行标记有一个硬编码的路径,但我想知道是否可以将路径指定为环境变量,然后在下面的代码中访问该环境变量,以便它可以在任何机器上运行如何在这个Maven插件中设置路径?,maven,sencha-cmd,Maven,Sencha Cmd,我是Maven插件的新手,我需要让这个插件运行sencha cmd工具来缩小我们的JavaScript应用程序,作为日常构建过程的一部分 当前可执行标记有一个硬编码的路径,但我想知道是否可以将路径指定为环境变量,然后在下面的代码中访问该环境变量,以便它可以在任何机器上运行 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</a
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>sencha-compile</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>C:\Sencha\Sencha\Cmd\4.0.2.67\sencha.exe</executable>
<arguments>
<argument>app</argument>
<argument>build</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
org.codehaus.mojo
execmaven插件
1.2.1
sencha编译
编译
执行官
C:\Sencha\Sencha\Cmd\4.0.2.67\Sencha.exe
应用程序
建造
要回答您的问题,您可以使用以下语法从maven pom文件中引用系统环境变量:
${env.NAME\u OF_VARIABLE}
有关更多详细信息,请参阅此链接:
如果将环境变量命名为PATH_TO_SENCHA_EXE,则可以这样引用它:
${env.PATH_TO_SENCHA_EXE}SENCHA.EXE
作为环境变量的替代,您可以考虑在POM中创建一个包含此路径的属性。然后,您可以通过在命令行上传递属性的新值或在pom中加载可能包含此属性的属性文件来更改用于不同环境的值。这里有很多选择
编辑: 我发现后一个建议已在以下链接(以及可能的其他地方)中涵盖:查看我的Sencha ExtJS 5+Sencha Cmd 5+Maven集成示例,网址为: 您必须设置环境变量:
- 在控制台中通过以下方式导出: $export SENCHA_CMD=“/path/to/your/SENCHA/CMD/5.0.0.116/SENCHA”
- 您还可以将此导出语句添加到
或~/.bashrc
文件中,以使其永久化/etc/profile
- 或者在Windows上添加新的环境变量
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Default build environment -->
<sencha.env>production</sencha.env>
</properties>
<profiles>
<!-- Development profile -->
<profile>
<id>dev</id>
<activation>
<property>
<name>env</name>
<value>development</value>
</property>
</activation>
<properties>
<sencha.env>testing</sencha.env>
</properties>
</profile>
<!-- Production profile -->
<profile>
<id>prod</id>
<activation>
<property>
<name>env</name>
<value>production</value>
</property>
</activation>
<properties>
<sencha.env>production</sencha.env>
</properties>
</profile>
</profiles>
那么...怎么样为什么使用外部程序?Sencha Cmd工具解决ExtJS应用程序中各种JavaScript文件之间的依赖关系。如果这些依赖关系没有得到解决,缩小会生成无法运行的代码。我喜欢您为路径创建pom属性,然后在命令行上设置值的想法。但我在你的链接中没有看到这种技术。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>sencha-compile</id>
<phase>compile</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- Set path to your Sencha Cmd executable-->
<executable>${env.SENCHA_CMD}</executable>
<arguments>
<argument>-sdk</argument>
<argument>${basedir}/src/main/webapp</argument>
<argument>app</argument>
<argument>build</argument>
<argument>--clean</argument>
<argument>--environment</argument>
<argument>${sencha.env}</argument>
<argument>--destination</argument>
<argument>${basedir}/src/main/webapp/build</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
$ mvn compile