Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant任务从字符串中选择单词_Ant - Fatal编程技术网

Ant任务从字符串中选择单词

Ant任务从字符串中选择单词,ant,Ant,假设我有字符串--“D:\ApEx\u Schema\Functions\new.sql@@@main\ONEVIEW\u Integration\3” 我需要将以下内容提取到diff变量中 -文件名 -文件路径 -以及版本(字符串的最后一个字符) 请使用ANT任务提供任何帮助 ====================================== 我正在尝试读取包含以下数据的txt文件:- .\ApEx_Schema\Functions\new.sql@@\main\ONEVIEW_In

假设我有字符串--“D:\ApEx\u Schema\Functions\new.sql@@@main\ONEVIEW\u Integration\3” 我需要将以下内容提取到diff变量中 -文件名 -文件路径 -以及版本(字符串的最后一个字符)

请使用ANT任务提供任何帮助

====================================== 我正在尝试读取包含以下数据的txt文件:-

.\ApEx_Schema\Functions\new.sql@@\main\ONEVIEW_Integration\3

.\ApEx_Schema\Functions\Functions.sql@@\main\ONEVIEW_Integration\3

.\ApEx_Schema\Indexes\Indexes.sql@@\main\ONEVIEW_Integration\2
以及尝试收集文件名、路径详细信息和版本,并使用SQL任务在数据库中更新这些信息。 尽管我的build.xml没有按预期提供输出。 任何建议和意见

我的Build.xml文件看起来像- ===================开始===========================


obiee复制文件生成文件


输入:@{detls}
路径:${Path}
文件:${File}
版本:${Version}
将值('3.2.12',“@{detls}','D:\ApEx\u Schema\Functions\Functions.sql','3',to_DATE('11-MAR-11','DD-MON-RR'),'Y')插入ROLTA_补丁文件应用选项卡(补丁编号,文件名,文件路径,文件版本,应用日期,状态);
在ROLTA_PATCH_选项卡(PATCH_NO、PATCH_NAME、APPL_NAME、APPL_DATE)中插入值('3.2.12'、'2.1.11'、'@{detls}',to_DATE('11-MAR-11'、'DD-MON-RR');


=======================================================

这不是Ant擅长的事情。 最简单的解决方案可能是使用:

(注意:这是在unix操作系统上测试的,因此如果在Windows上,可能需要调整路径分隔符处理方式。)

更新:

关于您的实现的一些注释

您可能需要为“for”任务命名名称空间:

<ac:for list="${src}" param="detls" delimiter="${line.separator}"
        xmlns:ac="antlib:net.sf.antcontrib">
    ...
</ac:for>

要引用由
propertyregex
设置的属性,请使用
${path}
而不是
@{path}

一个不需要贡献任务“propertyregex”或javascript的替代方法


输入:${candidate}
路径:${Path}
文件:${File}
版本:${Version}

Martin它适用于单个字符串,能否请您为一个文件中的多个字符串提供帮助。。。谢谢汉克斯·马丁。。。将检查您的代码并让您知道..谢谢
<replace file="D:\buildFRIDAY\database.txt" token=".\" value="D:\"/>  
<loadfile property="src" srcFile="D:\buildFRIDAY\database.txt"/> 

<path id="antclasspath"> 
    <fileset dir="D:\OraHome_1\oracledi\drivers">     
    <include name="ojdbc14.jar"/>    
    </fileset>  
</path>  

<for list="${src}" param="detls" delimiter="${line.separator}"> 
 <sequential>   
        <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
        <propertyregex property="path" input="@{detls}"
                       regexp="(.*)\\.*@@" select="\1" />
        <propertyregex property="file" input="@{detls}"
                       regexp=".*\\(.*)@@" select="\1" />
        <propertyregex property="version" input="@{detls}"
                       regexp=".*\\(.*)" select="\1" />

        <echo>
        Input:   @{detls}
        Path:    ${path}
        File:    ${file}
        Version: ${version}
        </echo>

        <if>
                <matches string="@{detls}" pattern=".sql"  /> 
         <then>

         </then>
        </if>

        <if>
                <matches string="@{detls}" pattern="[0-9]"  /> 
     <then>
            <sql     
                driver="oracle.jdbc.driver.OracleDriver"   
                url="jdbc:oracle:thin:@172.16.88.68:1521:rdev"   
                userid="rapid"    
                password="rapid"     
                print="yes"     
                classpathref="antclasspath">     

                Insert into ROLTA_PATCH_FILE_APP_TAB (PATCH_NO,FILE_NAME,FILE_PATH,FILE_VERSION,APPLIED_DATE,STATUS) values ('3.2.12',"@{detls}",'D:\ApEx_Schema\Functions\Functions.sql','3',to_date('11-MAR-11','DD-MON-RR'),'Y');

                Insert into ROLTA_PATCH_TAB (PATCH_NO,PATCH_NAME,APPL_NAME,APPLIED_DATE) values ('3.2.12','2.1.11','@{detls}',to_date('11-MAR-11','DD-MON-RR'));
            </sql>  
         </then>
        </if>
  </sequential> 
</for> 
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

<property name="candidate"
          value="D:\ApEx_Schema\Functions\new.sql@@\main\ONEVIEW_Integration\3" />

<propertyregex property="path" input="${candidate}"
               regexp="(.*)\\.*@@" select="\1" />
<propertyregex property="file" input="${candidate}"
               regexp=".*\\(.*)@@" select="\1" />
<propertyregex property="version" input="${candidate}"
               regexp=".*\\(.*)" select="\1" />

<echo>
Input:   ${candidate}
Path:    ${path}
File:    ${file}
Version: ${version}
</echo>
<scriptdef name="get_elements" language="javascript">
    <attribute name="candidate" />
    <attribute name="path-property" />
    <attribute name="file-property" />
    <attribute name="version-property" />
    <![CDATA[
        filesep = project.getProperty( "file.separator" );
        candidate = attributes.get( "candidate" );
        path = candidate.substring( 0, candidate.indexOf( "@@" ) );
        file = path.substring( path.lastIndexOf( filesep ) + 1 );
        path = path.substring( 0, path.lastIndexOf( filesep ) );
        version = candidate.substring( candidate.lastIndexOf( filesep )  + 1 );

        project.setProperty( attributes.get( "path-property" ), path );
        project.setProperty( attributes.get( "file-property" ), file );
        project.setProperty( attributes.get( "version-property" ), version );
    ]]>
</scriptdef>

<property name="candidate"
          location="D:\ApEx_Schema\Functions\new.sql@@\main\ONEVIEW_Integration\3"
          relative="yes" />
<get_elements candidate="${candidate}"
              path-property="path"
              file-property="file"
              version-property="version" />
<echo>
Input:   ${candidate}
Path:    ${path}
File:    ${file}
Version: ${version}
</echo>
<ac:for list="${src}" param="detls" delimiter="${line.separator}"
        xmlns:ac="antlib:net.sf.antcontrib">
    ...
</ac:for>
<propertyregex property="path"
               input="@{detls}"
               regexp="(.*)\\.*\@\@" select="\1"
               override="yes"/>