summaryrefslogtreecommitdiff
path: root/buildscripts/phing/tasks/PradoPearTask.php
blob: 5d4766a50af38b937cd259c4b42e4b43b15d097f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php

require_once 'phing/Task.php';
require_once('PEAR/PackageFileManager2.php');

/**
 * Task to run phpDocumentor for PRADO API docs.
 */
class PradoPearTask extends Task
{
	private $pkgdir;
	private $channel;
	private $version;
	private $state;
	private $category;
	private $package;
	private $summary;
	private $pkgdescription;
	private $notes;
	private $license;

	function setPkgdir($value)
	{
		$this->pkgdir=$value;
	}

	function setChannel($value)
	{
		$this->channel=$value;
	}

	function setVersion($value)
	{
		$this->version=$value;
	}

	function setState($value)
	{
		$this->state=$value;
	}

	function setCategory($value)
	{
		$this->category=$value;
	}

	function setPackage($value)
	{
		$this->package=$value;
	}

	function setSummary($value)
	{
		$this->summary=$value;
	}

	function setPkgdescription($value)
	{
		$this->pkgdescription=$value;
	}

	function setNotes($value)
	{
		$this->notes=$value;
	}

	function setLicense($value)
	{
		$this->license=$value;
	}

	/**
	 * Main entrypoint of the task
	 */
	function main()
	{
		$pkg = new PEAR_PackageFileManager2();

		$e = $pkg->setOptions(
			array(
				'baseinstalldir'    => 'prado',
				'packagedirectory'  => $this->pkgdir,
				'pathtopackagefile' => $this->pkgdir,
				'filelistgenerator' => 'file',
				'simpleoutput'      => true,
				'ignore'            => array(),
				'dir_roles'         =>
					array(
						'docs'          => 'doc',
						'examples'      => 'doc',
						'framework'     => 'php',
						'framework/js'  => 'doc',
						'framework/Vendor' => 'doc',
					),
				'exceptions' =>
					array(
						'requirements.php' => 'doc',
					),
			)
		);

		// PEAR error checking
		if (PEAR::isError($e))
			die($e->getMessage());
		$pkg->setPackage($this->package);
		$pkg->setSummary($this->summary);
		$pkg->setDescription($this->pkgdescription);
		$pkg->setChannel($this->channel);

		$pkg->setReleaseStability($this->state);
		$pkg->setAPIStability($this->state);
		$pkg->setReleaseVersion($this->version);
		$pkg->setAPIVersion($this->version);

		$pkg->setLicense($this->license);
		$pkg->setNotes($this->notes);
		$pkg->setPackageType('php');
		$pkg->setPhpDep('5.0.0');
		$pkg->setPearinstallerDep('1.4.2');

		$pkg->addRelease();
		$pkg->addMaintainer('lead','qxue','Qiang (Charlie) Xue','qiang.xue@gmail.com');

		$test = $pkg->generateContents();

		$e = $pkg->writePackageFile();

		if (PEAR::isError($e))
			echo $e->getMessage();
	}
}