1 /* 2 * Copyright (C) 2017 The Dagger Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dagger.internal.codegen; 18 19 import com.google.common.collect.FluentIterable; 20 import com.google.common.collect.ImmutableList; 21 22 /** The configuration options for compiler modes. */ 23 enum CompilerMode { 24 DEFAULT_MODE, 25 FAST_INIT_MODE("-Adagger.fastInit=enabled"), 26 JAVA7("-source", "7", "-target", "7"), 27 ; 28 29 /** Returns the compiler modes as a list of parameters for parameterized tests */ 30 static final ImmutableList<Object[]> TEST_PARAMETERS = 31 ImmutableList.copyOf( 32 new Object[][] {{CompilerMode.DEFAULT_MODE}, {CompilerMode.FAST_INIT_MODE}}); 33 34 private final ImmutableList<String> javacopts; 35 CompilerMode(String... javacopts)36 private CompilerMode(String... javacopts) { 37 this.javacopts = ImmutableList.copyOf(javacopts); 38 } 39 40 /** Returns the javacopts for this compiler mode. */ javacopts()41 FluentIterable<String> javacopts() { 42 return FluentIterable.from(javacopts); 43 } 44 45 /** 46 * Returns a {@link JavaFileBuilder} that builds {@link javax.tools.JavaFileObject}s for this 47 * mode. 48 */ javaFileBuilder(String qualifiedName)49 JavaFileBuilder javaFileBuilder(String qualifiedName) { 50 return new JavaFileBuilder(this, qualifiedName); 51 } 52 } 53