001    /*
002     * Copyright 2010-2013 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.jet.cli.common.modules;
018    
019    import com.intellij.util.SmartList;
020    import org.jetbrains.annotations.NotNull;
021    import org.jetbrains.annotations.Nullable;
022    
023    import java.util.List;
024    
025    /**
026     * This interface duplicates {@link kotlin.modules.Module}, because cli-common should not depend on kotlin-runtime.jar
027     */
028    public interface ModuleDescription {
029    
030        @NotNull
031        String getModuleName();
032    
033        @NotNull
034        String getOutputDir();
035    
036        @NotNull
037        List<String> getSourceFiles();
038    
039        @NotNull
040        List<String> getClasspathRoots();
041    
042        @NotNull
043        List<String> getAnnotationsRoots();
044    
045        class Impl implements ModuleDescription {
046    
047            private String name;
048            private String outputDir;
049            private final List<String> sources = new SmartList<String>();
050            private final List<String> classpath = new SmartList<String>();
051            private final List<String> annotations = new SmartList<String>();
052    
053            public void setName(String name) {
054                this.name = name;
055            }
056    
057            public void setOutputDir(String outputDir) {
058                this.outputDir = outputDir;
059            }
060    
061            public void addSourcePath(String path) {
062                sources.add(path);
063            }
064    
065            public void addClassPath(String path) {
066                classpath.add(path);
067            }
068    
069            public void addAnnotationPath(String path) {
070                annotations.add(path);
071            }
072    
073            @NotNull
074            @Override
075            public String getModuleName() {
076                return name;
077            }
078    
079            @NotNull
080            @Override
081            public String getOutputDir() {
082                return outputDir;
083            }
084    
085            @NotNull
086            @Override
087            public List<String> getSourceFiles() {
088                return sources;
089            }
090    
091            @NotNull
092            @Override
093            public List<String> getClasspathRoots() {
094                return classpath;
095            }
096    
097            @NotNull
098            @Override
099            public List<String> getAnnotationsRoots() {
100                return annotations;
101            }
102    
103            @Override
104            public String toString() {
105                return name +
106                       "\n\toutputDir=" + outputDir +
107                       "\n\tsources=" + sources +
108                       "\n\tclasspath=" + classpath +
109                       "\n\tannotations=" + annotations;
110            }
111        }
112    }