java 調用ant的自己定義task,預設不是build.xml 的一點問題

來源:互聯網
上載者:User

標籤:.exe   nis   started   start   ldl   print   error   except   erro   

java  調用ant的自己定義task,

    File buildFile = new File(".//ee-build.xml");

        // 建立一個ANT項目

        Project p = new Project();

        // 建立一個預設的監聽器,監聽項目構建過程中的日誌操作

        DefaultLogger consoleLogger = new DefaultLogger();

        consoleLogger.setErrorPrintStream(System.err);

        consoleLogger.setOutputPrintStream(System.out);

        consoleLogger.setMessageOutputLevel(Project.MSG_INFO);

        p.addBuildListener(consoleLogger);

        try {

            p.fireBuildStarted();

            // 初始化該項目

            p.init();

            ProjectHelper helper = ProjectHelper.getProjectHelper();

            // 解析項目的構建檔案

            helper.parse(p, buildFile);

            // 運行項目的某一個目標

            p.executeTarget("hello");

            p.fireBuildFinished(null);

        } catch (BuildException be) {

            p.fireBuildFinished(be);

        }

    }

假設java調用的target裡用antcall調用還有一個target,而且此target不在build.xml中定義。會出現target找不到。由於儘管上面指定檔案為ee-build.xml,可是ant預設找target還是會從build.xml中找。

或者p.setUserProperty("ant.file",buildFile.getAbsolutePath());

java 調用ant的自己定義task,預設不是build.xml 的一點問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.