1 /* 2 * Copyright 2017 JetBrains s.r.o. 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 kotlinx.atomicfu.plugin 18 19 import kotlinx.atomicfu.transformer.AtomicFUTransformer 20 import kotlinx.atomicfu.transformer.Variant 21 import org.apache.maven.plugin.AbstractMojo 22 import org.apache.maven.plugins.annotations.LifecyclePhase 23 import org.apache.maven.plugins.annotations.Mojo 24 import org.apache.maven.plugins.annotations.Parameter 25 import org.apache.maven.plugins.annotations.ResolutionScope 26 import java.io.File 27 28 @Mojo(name = "transform", 29 defaultPhase = LifecyclePhase.PROCESS_CLASSES, 30 requiresDependencyResolution = ResolutionScope.COMPILE) 31 class TransformMojo : AbstractMojo() { 32 /** 33 * Project classpath. 34 */ 35 @Parameter(defaultValue = "\${project.compileClasspathElements}", required = true, readonly = true) 36 lateinit var classpath: List<String> 37 38 /** 39 * Original classes directory. 40 */ 41 @Parameter(defaultValue = "\${project.build.outputDirectory}", property = "input", required = true) 42 lateinit var input: File 43 44 /** 45 * Transformed classes directory. 46 */ 47 @Parameter(defaultValue = "\${project.build.outputDirectory}", property = "output", required = true) 48 lateinit var output: File 49 50 /** 51 * Transformation variant: "FU", "VH", or "BOTH". 52 */ 53 @Parameter(defaultValue = "FU", property = "variant", required = true) 54 lateinit var variant: Variant 55 56 /** 57 * Verbose debug info. 58 */ 59 @Parameter(defaultValue = "false", property = "verbose", required = false) 60 var verbose: Boolean = false 61 executenull62 override fun execute() { 63 val t = AtomicFUTransformer(classpath, input, output, variant) 64 t.verbose = verbose 65 t.transform() 66 } 67 } 68