587
|
1 |
#============================================================================
|
|
2 |
#Name : ant.py
|
|
3 |
#Part of : Helium
|
|
4 |
|
|
5 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
6 |
#All rights reserved.
|
|
7 |
#This component and the accompanying materials are made available
|
|
8 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
#which accompanies this distribution, and is available
|
|
10 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
#
|
|
12 |
#Initial Contributors:
|
|
13 |
#Nokia Corporation - initial contribution.
|
|
14 |
#
|
|
15 |
#Contributors:
|
|
16 |
#
|
|
17 |
#Description:
|
|
18 |
#===============================================================================
|
|
19 |
|
|
20 |
""" Quality Ant task implementation. """
|
|
21 |
import integration.quality
|
|
22 |
import os
|
|
23 |
import traceback
|
|
24 |
|
|
25 |
def check_build_duplicates_task(project, task, attributes, elements):
|
|
26 |
""" This is the implementation of the checkBuildDuplicatesMacro Ant task."""
|
|
27 |
try:
|
|
28 |
if attributes.get('output') == None:
|
|
29 |
raise Exception("'output' attribute is not defined.")
|
|
30 |
output = str(attributes.get('output'))
|
|
31 |
task.log("Creating %s" % output)
|
|
32 |
output = open(output, "w+")
|
|
33 |
output.write("<?xml version=\"1.0\"?>\n<buildconflicts>\n")
|
|
34 |
components_per_file = {}
|
|
35 |
for eid in range(elements.get("fileset").size()):
|
|
36 |
dirscanner = elements.get("fileset").get(int(eid)).getDirectoryScanner(project)
|
|
37 |
dirscanner.scan()
|
|
38 |
for jfilename in dirscanner.getIncludedFiles():
|
|
39 |
filename = str(jfilename)
|
|
40 |
task.log("Parsing %s" % filename)
|
|
41 |
filename = os.path.join(str(dirscanner.getBasedir()), filename)
|
|
42 |
parser = integration.quality.AbldWhatParser(open(filename, 'r'))
|
|
43 |
parser.components_per_file = components_per_file
|
|
44 |
parser.parse()
|
|
45 |
|
|
46 |
for filename in components_per_file.keys():
|
|
47 |
if len(components_per_file[filename]) > 1:
|
|
48 |
output.write(" <file name=\"%s\">\n" % filename)
|
628
|
49 |
output.write("".join([" <component name=\"%s\"/>\n" % x for x in components_per_file[filename]]))
|
587
|
50 |
output.write(" </file>\n")
|
|
51 |
output.write("</buildconflicts>\n")
|
|
52 |
output.close()
|
|
53 |
except Exception, exc:
|
|
54 |
task.log('ERROR: %s' % exc)
|
|
55 |
traceback.print_exc()
|
|
56 |
raise exc
|