将FMPP与Gradle结合使用
我正在尝试将使用fmpp的ant任务转换为gradle。我无法让我的项目进行构建。我的build.xml文件中包含以下内容:将FMPP与Gradle结合使用,gradle,ant,build.gradle,fmpp,Gradle,Ant,Build.gradle,Fmpp,我正在尝试将使用fmpp的ant任务转换为gradle。我无法让我的项目进行构建。我的build.xml文件中包含以下内容: <project name="website"> <property file="build.properties" /> <property name="src.dir" location="src" /> <property name="build.dir" location="build" />
<project name="website">
<property file="build.properties" />
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<taskdef name="fmpp" classname="fmpp.tools.AntTask">
<classpath>
<pathelement location="lib/fmpp.jar"/>
</classpath>
</taskdef>
<target name="clean">
<delete dir="${build.dir}" />
</target>
<target name="dist">
<fmpp sourceRoot="${src.dir}" outputRoot="${build.dir}">
<data expandProperties="yes">
base_url: ${base_url}
google_analytics_number: ${google_analytics_number}
mail_user: ${mail_user}
mail_password: ${mail_password}
mail_recipient: ${mail_recipient}
upload_folder: ${upload_folder}
host: ${host}
port: ${port}
</data>
</fmpp>
</target>
</project>
但是当我运行它时,我得到了以下错误
FMPP处理会话失败。
原因:freemarker.core.InvalidReferenceException:data/header.htm中第15行第47列的表达式base_url未定义
因此,htm文件中的模板变量似乎没有在我的构建中正确地提取和实现。我不知道该怎么解决这个问题。fmpp有几个gradle插件,但文档非常有限,我很难让它们中的任何一个正常工作。如果任何人有任何建议或周围的工作将不胜感激
***更新
下面是一个试图应用的htm文件示例
<head>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$page = basename($_SERVER['PHP_SELF']);
require_once($_SERVER['DOCUMENT_ROOT'] . '/js/functions.php');
?>
<title>
<#if title??> ${title}
<#else> CompSci Resources, LLC | The Complete EDGAR and XBRL Filing Platform, and more!
</#if>
</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script type='text/javascript' src='${base_url}/js/bootstrap-filestyle.min.js'> </script>
<script type='text/javascript' src='${base_url}/js/bootstrap.min.js'></script>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jcarousel/0.3.4/jquery.jcarousel.js'></script>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jcarousel/0.3.4/jquery.jcarousel-autoscroll.min.js'></script>
<script type='text/javascript' src='${base_url}/js/compsci.js'></script>
<script type='text/javascript' src='${base_url}/js/carousel.js'></script>
<script type='text/javascript' src='${base_url}/js/readmore.js'></script>
<link rel='shortcut icon' href='${base_url}/images/littlelogo.png' >
<link rel='stylesheet' type='text/css' href='${base_url}/css/jcarousel.css' >
<link rel='stylesheet' type='text/css' href='${base_url}/css/bootstrap.css'>
<link rel='stylesheet' type='text/css' media='screen, projection' href='${base_url}/css/compsci.css'>
<style type='text/css'>
@media screen and (-webkit-min-device-pixel-ratio:0) {
h2 { font-weight: normal; }
.csr-services-popper-left { margin-top:11px; }
}
</style>
<!-- Google Analytics -->
<script type='text/javascript'>
//Google Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '${google_analytics_number}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<meta charset="UTF-8">
<meta name="language" content="en">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
${title}
CompSci Resources,LLC |完整的EDGAR和XBRL归档平台,等等!
@媒体屏幕和(-webkit最小设备像素比:0){
h2{字体大小:正常;}
.csr服务波普尔左{页边空白顶部:11px;}
}
//谷歌分析
var _gaq=_gaq | |[];
_gaq.push([''u setAccount','${google\u analytics\u number}');
_gaq.push([''u trackPageview']);
(功能(){
var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;
ga.src=('https:'==document.location.protocol?'https://ssl' : 'http://www“)+”.google analytics.com/ga.js';
var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);
})();
问题在于,从gradle.properties
读取的属性和数据属性的名称完全相同。要修复它,您需要使用project
实例引用隐藏在属性下的值,例如:
base_url = project.base_url
看看我刚准备好的。它运行时没有任何错误。如果在gradle.properties
中重命名属性,则可以跳过project
,这是port2
属性的情况-故意重命名 在传递给数据的闭包中尝试冒号:
而不是等号=
,例如:base\u-url:base\u-url
。我尝试过了,但它给出了以下错误语句标签,可能无法在构建脚本中使用。如果您试图配置名为“base_url”的属性,请将“:”替换为“=”或“”,否则将无法达到预期效果。@第24行第19列。base_url:base_url我需要快速查看一下我的旧项目,它以类似的方式使用ant。将保留您的海报。base\u url
是Ant中设置的属性,对吗?如果是这样,您需要从Ant项目中提取它,因为Gradle无法直接访问它。请尝试base\u url=ant.base\u url
。这样做会导致以下错误--在评估根项目“csWebsite”时出现问题。>没有此类属性:类的base_url:org.gradle.api.internal.project.DefaultAntBuilderI在运行上述--[ant:fmpp]错误[ant:fmpp]任务中止时出现以下错误:fmpp处理会话失败。原因:freemarker.core.InvalidReferenceException:Expression base_url在data/header.htm的第15行第47列中未定义。我在main中发布了htm文件question@EdDunn,请参阅更新的回购协议。API中的方法启发我尝试这种方法。它只是以TDD(文本数据定义)格式表示模板数据。你能接受我的回答吗?没问题。再次感谢
base_url = project.base_url