From a5bce57edfda917ac9740542b3ea07b479d62a8f Mon Sep 17 00:00:00 2001 From: Taeyoung Son Date: Fri, 23 May 2014 16:28:25 +0900 Subject: BUILD: Fixed bug in TemplateEngineBuilder Fixed bug in TemplateEngineBuilder Change-Id: I54dbf3e6c0462302ffb2dacf2540476deb4a3dad Signed-off-by: Taeyoung Son --- .../common/builder/BuildDependencyListener.java | 2 +- .../src/org/tizen/common/builder/BuildProcess.java | 23 +++++++++++++++++++- .../common/builder/IBuildProcessListener.java | 25 ++++++++++++++++++++++ .../tizen/common/builder/core/AbstractBuilder.java | 5 +++-- .../common/builder/core/TemplateEngineBuilder.java | 2 +- .../tizen/common/builder/exception/Location.java | 25 ++++++++++++++++++++++ .../src/org/tizen/common/builder/MockBuilder.java | 2 +- 7 files changed, 78 insertions(+), 6 deletions(-) diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/BuildDependencyListener.java b/org.tizen.common.builder/src/org/tizen/common/builder/BuildDependencyListener.java index 4e090dd3a..0629c992f 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/BuildDependencyListener.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/BuildDependencyListener.java @@ -1,5 +1,5 @@ /* - * BuildListener.java + * common * * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. * diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java index 8986c9427..f140a147d 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java @@ -1,5 +1,5 @@ /* - * AbstractBuildProcess.java + * BuildProcess.java * * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. * @@ -218,4 +218,25 @@ public class BuildProcess implements IBuildProcess { public void removeListener(IBuildListener listener) { listeners.remove(listener); } + + public IBuilder getLastBuilder() { + if (builders == null + || builders.isEmpty()) { + return null; + } + return builders.get(builders.size()-1); + } + + public IBuilder getBuilder(Class clazz) { + if (builders == null + || builders.isEmpty()) { + return null; + } + for (IBuilder builder : builders) { + if (builder.getClass().equals(clazz)) { + return builder; + } + } + return null; + } } diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/IBuildProcessListener.java b/org.tizen.common.builder/src/org/tizen/common/builder/IBuildProcessListener.java index ab703f744..485f3fbc8 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/IBuildProcessListener.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/IBuildProcessListener.java @@ -1,3 +1,28 @@ +/* + * IBuildProcessListener.java + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Taeyoung Son + * Hyeongseok Heo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ package org.tizen.common.builder; public interface IBuildProcessListener extends IBuildListener { diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/core/AbstractBuilder.java b/org.tizen.common.builder/src/org/tizen/common/builder/core/AbstractBuilder.java index 67c3c87d1..b3c419633 100755 --- a/org.tizen.common.builder/src/org/tizen/common/builder/core/AbstractBuilder.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/core/AbstractBuilder.java @@ -149,12 +149,13 @@ implements IBuilder * @param byteArray * @throws IOException */ - public void addOutputResource(BuildResult result, IResource resource, byte[] byteArray) throws IOException { - IResource outResource = new Resource(getOutputFileHandler(), resource.getPath()); + public IResource addOutputResource(BuildResult result, IResource resource, String outputPath, byte[] byteArray) throws IOException { + IResource outResource = new Resource(getOutputFileHandler(), outputPath); outResource.setContents(byteArray); result.addDependency(resource, outResource); result.setResult(Status.SUCCESS); + return outResource; } abstract protected BuildResult doBuild(IResource resource) throws BuildException; diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/core/TemplateEngineBuilder.java b/org.tizen.common.builder/src/org/tizen/common/builder/core/TemplateEngineBuilder.java index def18fb7b..d04685958 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/core/TemplateEngineBuilder.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/core/TemplateEngineBuilder.java @@ -89,7 +89,7 @@ public abstract class TemplateEngineBuilder extends AbstractBuilder { templateEngine.generate( templateKey, getModelProvider(), baos ); //$NON-NLS-1$ final BuildResult ret = new BuildResult(Status.SUCCESS); - addOutputResource(ret, resource, baos.toByteArray()); + addOutputResource(ret, resource, resource.getPath(), baos.toByteArray()); return ret; } catch (Exception e) { throw new BuildException( e ); diff --git a/org.tizen.common.builder/src/org/tizen/common/builder/exception/Location.java b/org.tizen.common.builder/src/org/tizen/common/builder/exception/Location.java index 5a901e7ee..1182365cb 100644 --- a/org.tizen.common.builder/src/org/tizen/common/builder/exception/Location.java +++ b/org.tizen.common.builder/src/org/tizen/common/builder/exception/Location.java @@ -1,3 +1,28 @@ +/* + * Location.java + * + * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Taeyoung Son + * Hyeongseok Heo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Contributors: + * - S-Core Co., Ltd + * + */ package org.tizen.common.builder.exception; public class Location { diff --git a/org.tizen.common.builder/test/src/org/tizen/common/builder/MockBuilder.java b/org.tizen.common.builder/test/src/org/tizen/common/builder/MockBuilder.java index 50ae293bb..246de6c12 100644 --- a/org.tizen.common.builder/test/src/org/tizen/common/builder/MockBuilder.java +++ b/org.tizen.common.builder/test/src/org/tizen/common/builder/MockBuilder.java @@ -25,7 +25,7 @@ public class MockBuilder extends AbstractBuilder { protected BuildResult doBuild(IResource resource) throws BuildException { BuildResult result = new BuildResult(Status.UNKNOWN); try { - addOutputResource(result, resource, IOUtil.getBytes(resource.getContents())); + addOutputResource(result, resource, resource.getPath(), IOUtil.getBytes(resource.getContents())); } catch (IOException e) { e.printStackTrace(); } -- cgit v1.2.3