Tru*_*che 3 javascript maven maven-archetype
尝试从我的Maven原型生成项目时遇到问题。当没有解析javascript文件时,一切都很好(即,排除在archetype-metadata.xml文件之外)。但是我需要${MyProject}在一些js文件中插入变量,以免排除项目js文件。
这是我的原型配置:(archetype-metadata.xml文件)
<!-- Project Web Content -->
<fileSet filtered="true" packaged="false" encoding="UTF-8">
<directory>src/main/webapp</directory>
<excludes>
<exclude>js/libs/**/*</exclude>
<exclude>js/angular-mock/**/*</exclude>
<exclude>template/**/*</exclude>
<exclude>views/**/*</exclude>
<exclude>img/**/*</exclude>
<exclude>font/**/*</exclude>
<exclude>icones/**/*</exclude>
<exclude>css/**/*</exclude>
</excludes>
</fileSet>
Run Code Online (Sandbox Code Playgroud)
这是我在3个测试用例中遇到的不同错误(我尝试排除在archetype-metadata.xml某些出现错误的文件中):
Unable to create project from archetype [com.mypackage.archetypes:ngwis-project:2.0-SNAPSHOT]
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates: Encountered "}" at line 14, column 25 of archetype-resources/__rootArtifactId__Web/src/main/webapp/js/__rootArtifactId__/application.js
Was expecting one of:
"[" ...
"{" ...
<STRING_LITERAL> ...
"true" ...
"false" ...
<INTEGER_LITERAL> ...
<FLOATING_POINT_LITERAL> ...
<IDENTIFIER> ...
"{" ...
Unable to create project from archetype [com.mypackage.archetypes:ngwis-project:2.0-SNAPSHOT]
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates: Encountered "() { return item; },\r\n\t\t\t\t\t columns : function() { return scope.columns; },\r\n\t\t\t\t\t service: function() { return scope.service; },\r\n\t\t\t\t\t newItem: function() { return isNewItem; }\r\n\t\t\t\t\t }\r\n\t\t\t\t\t });\r\n\r\n\t\t\t\t\t\tmodalInstance.result.then(\r\n\t\t\t\t\t\t\tfunction (selectedItem) {\r\n\t\t\t\t\t\t\t\tscope.onclosemodal(selectedItem);\r\n\t\t\t\t\t\t\t\tscope.tableParams.reload();\r\n\t\t\t\t\t\t\t}, function () {\r\n\t\t\t\t\t\t\t\tconsole.log(\'Modal dismissed at: \' + new Date());\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t};\r\n\t\t\t\t\t\r\n\t\t\t\t\tscope.isSelectable = function() {\r\n\t\t\t\t\t\treturn scope.select && scope.select !== angular.noop;\r\n\t\t\t\t\t};\r\n\t\t\t\t\tscope.totalElements = 0;\r\n\t\t\t\t\tscope.hasElements = function () {\r\n\t\t\t\t\t\treturn (scope.totalElements > 0);\r\n\t\t\t\t\t}\r\n\t\t\t\t scope.tableParams = new ngTableParams({\r\n\t\t\t\t page: 1, // show first page\r\n\t\t\t\t count: scope.displayedLines, // count per page\r\n\t\t\t\t filter : scope.filter || {},\t// filtering\r\n\t\t\t\t sorting : scope.sort || {}\t\t//order by\r\n\t\t\t\t }, {\r\n\t\t\t\t \tcounts : [10, 25, 50, 100],\r\n\t\t\t\t total: 0, // length of data\r\n\t\t\t\t getData: function(" at line 143, column 66 of archetype-resources/__rootArtifactId__Web/src/main/webapp/js/__rootArtifactId__/directives/directives.js
Was expecting one of:
"," ...
"}" ...
Unable to create project from archetype [com.mypackage.archetypes:ngwis-project:2.0-SNAPSHOT]
org.apache.maven.archetype.exception.ArchetypeGenerationFailure: Error merging velocity templates: Encountered "(value) { \n\t\t" at line 16, column 41 of archetype-resources/__rootArtifactId__Web/src/main/webapp/js/__rootArtifactId__/controllers/controllers.js
Was expecting one of:
"," ...
")" ...
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?谢谢
我发现了问题,我与$js文件中的字符发生冲突:解析器将$变量用于变量(例如$ {rootArtifactId})。解决方案是定义您自己的变量${dollar}:
#set( $dollar = '$' )
Run Code Online (Sandbox Code Playgroud)
例如:
$scope.$watch(...)必须替换为${dollar}scope.${dollar}watch(...)
该#字符必须使用相同的技巧。
| 归档时间: |
|
| 查看次数: |
1777 次 |
| 最近记录: |