[ https://issues.apache.org/jira/browse/GROOVY-11666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17951849#comment-17951849 ]
Eric Milles commented on GROOVY-11666: -------------------------------------- Have you tested this scenario with {{javac}}? Most behavior is modeled after that. In fact it can be embedded for joint compilation, so we want to stay in alignment. > Incremental compilation in groovyc Ant task is not working properly > ------------------------------------------------------------------- > > Key: GROOVY-11666 > URL: https://issues.apache.org/jira/browse/GROOVY-11666 > Project: Groovy > Issue Type: Bug > Affects Versions: 4.0.26 > Reporter: Björn Kautler > Priority: Major > > Given this small MCVE: > {code:none} > ./build.xml > <?xml version="1.0" encoding="UTF-8"?> > <project name="foo" xmlns:groovy="antlib:org.codehaus.groovy.ant" > xmlns:ivy="antlib:org.apache.ivy.ant"> > <property name="config.ivy.version" value="2.2.0"/> > <property name="lib.dir" location="build/libs"/> > <property name="ivy.jar.dir" location="${lib.dir}/ivy"/> > <property name="ivy.jar.filename" value="ivy-${config.ivy.version}.jar"/> > <property name="ivy.jar.file" > location="${ivy.jar.dir}/${ivy.jar.filename}"/> > <target name="check-ivy"> > <available property="ivy.jar.present" > file="${ivy.jar.file}" > type="file"/> > </target> > <target name="download-ivy" depends="check-ivy" unless="ivy.jar.present"> > <mkdir dir="${ivy.jar.dir}"/> > <get > src="https://repo.maven.apache.org/maven2/org/apache/ivy/ivy/${config.ivy.version}/ivy-${config.ivy.version}.jar" > dest="${ivy.jar.file}" usetimestamp="true"/> > </target> > <target name="init-ivy" depends="download-ivy" unless="ivy.done"> > <property name="ivy.retrieve.pattern" > value="${lib.dir}/[conf]/[artifact](-[classifier]).[ext]"/> > <taskdef resource="org/apache/ivy/ant/antlib.xml" > classpath="${ivy.jar.file}" loaderref="ivy.loader" > uri="antlib:org.apache.ivy.ant"/> > </target> > <target name="retrieve" description="retrieve the dependencies" > depends="init-ivy" unless="ivy.done"> > <ivy:retrieve sync="true"/> > <ivy:retrieve pattern="${lib.dir}/ivy/[artifact]-[revision].[ext]" > organisation="org.apache.ivy" module="ivy" revision="${config.ivy.version}" > conf="default" inline="true"/> > <property name="ivy.done" value="true"/> > </target> > <target name="compile" depends="retrieve"> > <mkdir dir="build/classes/main"/> > <taskdef resource="org/codehaus/groovy/antlib.xml" > uri="antlib:org.codehaus.groovy.ant"> > <classpath> > <fileset dir="${lib.dir}/groovy-ant" includes="*.jar"/> > </classpath> > </taskdef> > <groovy:groovyc srcdir="src" destdir="build/classes/main"> > <classpath> > <fileset dir="${lib.dir}/compile" includes="*.jar"/> > </classpath> > </groovy:groovyc> > </target> > </project> > ./ivy.xml > <?xml version="1.0" encoding="UTF-8"?> > <ivy-module version="2.0" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="https://ant.apache.org/ivy/schemas/ivy.xsd"> > <info organisation="foo" module="foo"/> > <configurations> > <conf name="compile" description="Compile dependencies" > visibility="private" transitive="false"/> > <conf name="groovy-ant" description="Dependencies for Groovy Ant > tasks" visibility="private"/> > </configurations> > <dependencies defaultconfmapping="%->default"> > <dependency org="org.apache.groovy" name="groovy" rev="4.0.26" > conf="compile"/> > <dependency org="org.apache.groovy" name="groovy-ant" rev="4.0.26" > conf="groovy-ant"/> > <dependency org="org.apache.groovy" name="groovy-groovydoc" > rev="4.0.26" conf="groovy-ant"/> > </dependencies> > </ivy-module> > ./src/Bar.groovy > class Bar { > def foo = new Foo() > } > ./src/Foo.groovy > class Foo { > } > {code} > If you now do {{ant compile}}, everything works just fine. > Now modify only the class {{Bar}} in some way (that does not remove the > reference to {{Foo}}). > And now run {{ant compile}} again. > The {{groovyc}} task wants to be nice and only compile the changed {{Bar}} > class, but it fails with {{2: unable to resolve class Foo}}. > The {{groovyc}} task should probably automatically contain its destination > directory in the classpath to fix this. > This is also the work-around I am using, by adding {{<pathelement > location="build/classes/main"/>}} inside the {{<classpath>}}. > This makes the incremental compiling work as expected as now the previously > compiled classes are part of the classpath and can be found. -- This message was sent by Atlassian Jira (v8.20.10#820010)