« Return to Thread: Excluding a Test Source File

Re: Excluding a Test Source File

by Paul Speed-2 :: Rate this Message:

Reply to Author | View in Thread

Does gradle show us the actual javac command run?

Note: if it was referenced by some other file then it would be compiled
before that file.

I build multiple projects from the same tree and use excludes to avoid
compiling the other project source.  So, at least for regular code
compilation the excludes can work.  Actually, it's even working for my
test code.

Example:
testCompile {
     include( "org/progeeks/meta/**" )
     exclude( "org/progeeks/meta/file/**" )
     exclude( "org/progeeks/meta/jdbc/**" )
     ...etc...
}

And I'm still using 0.5.2.

When my actual code->code dependencies weren't clean then it would
compile the excluded classes anyway.  Which is why I suggested that.
All of your symptoms fit even if reality doesn't. :)

-Paul

JerodLass wrote:

> It's a test file that isn't referenced by any other test, and compiling fails
> on the file so no .class file is generated.  Also, I can't figure out why
> but it looks like the file I'm trying to ignore is compiled first.
>
>
> Paul Speed-2 wrote:
>> Note also: I don't know if this is affecting you but if another .java
>> file refers to the excluded one then it will get compiled anyway.  The
>> javac command will compile any source files you specify on the command
>> line as well as any source files on its path necessary to build
>> dependent classes.
>>
>> Does the .class file exist after compiling even though you are excluding
>> it?
>>
>> -Paul
>>
>> JerodLass wrote:
>>> I clean before every build, but I just moved everything but the source
>>> and it
>>> still happens.  Does this feature work for other people?  If you have a
>>> test
>>> class that doesn't compile and you exclude it from compile and
>>> compileTests
>>> with gradle 0.6.1, does it skip it?  I have had success skipping tests
>>> this
>>> way, but this is the first time I am trying not to compile a file.
>>>
>>>
>>> Steve Appling wrote:
>>>> The tests are actually run against the class files, so it you have
>>>> previously
>>>> compiled the tests before excluding it, the unwanted class file may
>>>> still
>>>> be in
>>>> the build directory.
>>>>
>>>> Try running "gradle clean test"
>>>>
>>>> JerodLass wrote:
>>>>> I'm building a project with a test file that imports a class that I see
>>>>> no
>>>>> evidence actually exists.  The test file is 95% commented out so I know
>>>>> I
>>>>> can safely ignore it, but it's not mine so I cannot change it.  Thus, I
>>>>> would like to exclude it from the build (which doesn't run tests yet
>>>>> anyway).  I added the following line to the build file:
>>>>>
>>>>> compileTests.exclude(**/BadTestFile.java)
>>>>>
>>>>> When I build, the number of files to compile decreases by 1, but I
>>>>> still
>>>>> get
>>>>> the error.  The file looks to be effectively excluded by gradle in the
>>>>> debug
>>>>> output, but the javac command that is executed still gives -sourcepath
>>>>> /project/testsrc so it still tries to compile every test class and I
>>>>> get
>>>>> an
>>>>> error.  Basically, I am getting compile errors from a class that "isn't
>>>>> being compiled." Am I doing something wrong or does this functionality
>>>>> get
>>>>> lost somewhere before making it to the compiler?
>>>>>
>>>>> Thanks for any help,
>>>>> Jerod
>>>> --
>>>> Steve Appling
>>>> Automated Logic Research Team
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>>
>>>>     http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>>
>>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Excluding a Test Source File