001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2008-2011 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * Sonar is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.api.resources;
021    
022    import com.google.common.collect.Lists;
023    import org.apache.commons.lang.StringUtils;
024    
025    import java.util.Collection;
026    import java.util.List;
027    
028    /**
029     * @TODO Actually this class incorrectly named, because provides information not about project, but about Java project.
030     *       And seems that only core plugins use this class.
031     * 
032     * @since 1.10
033     */
034    public final class ProjectUtils {
035    
036      private ProjectUtils() {
037        // utility class with only static methods
038      }
039    
040      /**
041       * @deprecated since 2.6 use JavaUtils.getTargetVersion() instead.
042       */
043      @Deprecated
044      public static String getJavaVersion(Project project) {
045        String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.target") : null;
046        return StringUtils.isNotBlank(version) ? version : "1.5";
047      }
048    
049      /**
050       * @deprecated since 2.6 use JavaUtils.getSourceVersion() instead.
051       */
052      @Deprecated
053      public static String getJavaSourceVersion(Project project) {
054        String version = project.getConfiguration() != null ? project.getConfiguration().getString("sonar.java.source") : null;
055        return StringUtils.isNotBlank(version) ? version : "1.5";
056      }
057    
058      /**
059       * @since 2.7
060       */
061      public static List<java.io.File> toIoFiles(Collection<InputFile> inputFiles) {
062        List<java.io.File> files = Lists.newArrayList();
063        for (InputFile inputFile : inputFiles) {
064          files.add(inputFile.getFile());
065        }
066        return files;
067      }
068    }