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 AHEAD_OF_TIME_SUBCOMPONENTS_MODE( 27 "-Adagger.experimentalAheadOfTimeSubcomponents=enabled", 28 "-Adagger.emitModifiableMetadataAnnotations=disabled"), 29 JAVA7("-source", "7", "-target", "7"), 30 ; 31 32 /** Returns the compiler modes as a list of parameters for parameterized tests */ 33 static final ImmutableList<Object[]> TEST_PARAMETERS = 34 ImmutableList.copyOf( 35 new Object[][] {{CompilerMode.DEFAULT_MODE}, {CompilerMode.FAST_INIT_MODE}}); 36 37 private final ImmutableList<String> javacopts; 38 CompilerMode(String... javacopts)39 private CompilerMode(String... javacopts) { 40 this.javacopts = ImmutableList.copyOf(javacopts); 41 } 42 43 /** Returns the javacopts for this compiler mode. */ javacopts()44 FluentIterable<String> javacopts() { 45 return FluentIterable.from(javacopts); 46 } 47 48 /** 49 * Returns a {@link JavaFileBuilder} that builds {@link javax.tools.JavaFileObject}s for this 50 * mode. 51 */ javaFileBuilder(String qualifiedName)52 JavaFileBuilder javaFileBuilder(String qualifiedName) { 53 return new JavaFileBuilder(this, qualifiedName); 54 } 55 } 56