1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.util;
16  
17  import org.apache.tools.ant.BuildException;
18  import org.apache.tools.ant.Task;
19  
20  /**
21   * <a href="PropsUtilTask.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Brian Wing Shun Chan
24   */
25  public class PropsUtilTask extends Task {
26  
27      public void execute() throws BuildException {
28          ClassLoader antClassLoader = getClass().getClassLoader();
29  
30          Thread currentThread = Thread.currentThread();
31  
32          ClassLoader contextClassLoader = currentThread.getContextClassLoader();
33  
34          try {
35              currentThread.setContextClassLoader(antClassLoader);
36  
37              getProject().setUserProperty(_result, PropsUtil.get(_key));
38          }
39          finally {
40              currentThread.setContextClassLoader(contextClassLoader);
41          }
42      }
43  
44      public void setKey(String key) {
45          _key = key;
46      }
47  
48      public void setResult(String result) {
49          _result = result;
50      }
51  
52      private String _key;
53      private String _result;
54  
55  }