/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License.
 */
package groovy.ant

import org.junit.jupiter.api.Test

class Groovy8951Test extends AntTestCase {
    @Test
    void testSetterAppearsInTraitClass() {
//        def debugLogger = new org.apache.tools.ant.DefaultLogger()
//        debugLogger.setMessageOutputLevel(4)
//        debugLogger.setOutputPrintStream(System.out)
//        debugLogger.setErrorPrintStream(System.err)

        doInTmpDir { ant, baseDir ->
            baseDir.src {
                p1 {
                    'Validateable.groovy'('''
                        package p1
                        @groovy.transform.CompileStatic
                        trait Validateable {
                            List errors
                            List getErrors() {
                                errors
                            }
                            abstract void foo()
                        }
                    ''')
                }
                p2 {
                    'Main.java'('''
                        package p2;
                        public class Main {
                            MyValidateable temp = new MyValidateable();
                        }
                    ''')
                    'OtherTrait.groovy'('''
                        package p2
                        trait OtherTrait {
                            void otherMethod() { println new Date() }
                        }
                    ''')
                    'MyValidateable.groovy'('''
                        package p2
                        class MyValidateable implements OtherTrait, p1.Validateable {
                            void foo() {}
                        }
                    ''')
                }
            }
//            ant.project.addBuildListener(debugLogger)
            ant.mkdir(dir: 'build')
            ant.taskdef(name: 'groovyc', classname: 'org.codehaus.groovy.ant.Groovyc')
            ant.groovyc(srcdir: 'src', destdir: 'build', includes: 'p1/*')
            ant.groovyc(srcdir: 'src', destdir: 'build', includes: 'p2/*' /*, keepStubs: true*/) {
                javac()
            }
        }
    }
}
