Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source not found #57

Open
lschuetze opened this Issue Nov 7, 2014 · 15 comments

Comments

Projects
None yet
8 participants
@lschuetze
Copy link

lschuetze commented Nov 7, 2014

I am trying to build http://github.com/dresden-ocl/dresdenocl repository. But if I run mvn cobertura:cobertura coveralls:report cobertura runs fine. But coveralls-maven-plugin reports a problem:

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.0.1:report (default-cli) on project org.dresdenocl: I/O operation failed: No source found for testpackage/Class1_DefAspect_testSortedByIteratorExp01.aj -> [Help 1]

The file in question lies in /tests/org.dresdenocl.tools.codegen.ocl2java.test.aspectj/src/testpackage/constraints so I really ask me why it is not looking into testpackage/constraints/ but in testpackage/.

Tried adding the directory to sourceDirectory but this does not help.

As you can see it is a multi module setup. Maybe you see where the problem comes from.

@trautonen trautonen added the defect label Nov 8, 2014

@lschuetze

This comment has been minimized.

Copy link
Author

lschuetze commented Nov 13, 2014

I've run mvnDebug and remote debugged the build process.
Appearently, the issue seems to come from cobertura which fails to save the path of the AspectJ files correctly.

The java classes that are weaved rely in the package testpackage while those aspects have the package testpackage.constraints. The package names reflect the physical folder structure.

Somehow, there are several entries in the cobertura.xml regarding the weaved aspect:

  1. <class name="testpackage.Class1$Class1_DefAspect_testSortedByIteratorExp01$1" filename="testpackage/Class1_DefAspect_testSortedByIteratorExp01.aj" line-rate="0.0" branch-rate="0.0" complexity="0.0">
  2. <class name="testpackage.constraints.Class1_DefAspect_testSortedByIteratorExp01" filename="testpackage/constraints/Class1_DefAspect_testSortedByIteratorExp01.aj" line-rate="0.0" branch-rate="0.0" complexity="0.0">

The second one is the right one. Using -XnoInline does not have the desired effect.

Extract from Class1_DefAspect_testSortedByIteratorExp01.aj

public privileged aspect Class1_DefAspect_testSortedByIteratorExp01 {
...
    public java.util.List<Integer> testpackage.Class1.testSortedByIteratorExp01() {
        ...
    }
}

Therefore, I don't see the issue with coveralls-maven-plugin anymore. However, cobertura-maven-plugin has approx. 1100 days on average to fix a reported bug. I don't see this being fixed soon.

@trautonen

This comment has been minimized.

Copy link
Owner

trautonen commented Dec 12, 2014

Nice that you found a workaround (saved me the trouble of debugging this). There's not much I can do on the report parsing side to fix such issues. I could add a feature that you can ignore some files in the report, but I think you can do the same in the coverage tools also, so it's not worth the effort to create feature duplication in two different tools.

@viniciuspires

This comment has been minimized.

Copy link

viniciuspires commented Feb 4, 2015

Tapio, looks like my build is failing because of a similar issue (see the end of the log: https://travis-ci.org/viniciuspires/reqlist/jobs/49405357). It says:

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.0.1:report (default-cli) on project reqlist: I/O operation failed: No source found for org/reqlist/entity/view/AndamentoProjeto_.java -> [Help 1]

For my open-source project: https://github.com/viniciuspires/reqlist

Any ideas of why this is happening?

@pdurbin

This comment has been minimized.

Copy link

pdurbin commented Aug 31, 2015

@viniciuspires I'm getting a similar error for https://github.com/pdurbin/addressbookmvc/tree/master/examples/javaee7 and I'm wondering how you got https://coveralls.io/github/viniciuspires/reqlist working. Like you, I'm seeing an error about a file with an underscore, which is strange because the underscore isn't in the original file name:

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:3.0.1:report (default-cli) on project javaee7addressbook: I/O operation failed: No source found for com/greptilian/addressbookmvc/javaee7/Person_.java

Any tips on resolving this error?

@viniciuspires

This comment has been minimized.

Copy link

viniciuspires commented Aug 31, 2015

@pdurbin I don't remember exactly, but this classes are generated by the JPA to contain the related entity metadata, and the coveralls-maven-plugin was somehow trying to find its source, which doesn't exist. In my case, I think I somehow disabled this behaviour on JPA, and started to use only the entities I made.

Anyway, this serves as a workaround, I don't know how this should be solved, but I think that maybe there's a way to make coveralls-maven-plugin ignore generated classes, and don't fail because of that.

@pdurbin

This comment has been minimized.

Copy link

pdurbin commented Aug 31, 2015

@viniciuspires nevermind! I fixed this by changing exclude-unlisted-classes from false to true in src/main/resources/META-INF/persistence.xml in pdurbin/addressbookmvc@4e9f2ed

I just upvoted http://stackoverflow.com/questions/23326456/why-is-there-a-class-with-entity-name-plus-an-underscore-for-jpa-entity-class and added an answer.

@trautonen

This comment has been minimized.

Copy link
Owner

trautonen commented Sep 1, 2015

The problem is that this plugin cannot deal with any kind of code generation, because it requires the original source to be available. It is also questionable if you should run your coverage metrics based on generated code, which actually means you are testing a code generator, not your own code.

As a general solution, all generated code should be excluded from coverage tools.
JaCoCo: http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html#excludes
Cobertura (Instrumentation): http://www.mojohaus.org/cobertura-maven-plugin/usage.html

dgroup pushed a commit to AlexeyZhulyov/nc_edu_web-container that referenced this issue Apr 6, 2016

Deployment module was excluded from jacoco report
Coveralls+Jacoco doesn't work with generated code
trautonen/coveralls-maven-plugin#57
@muzir

This comment has been minimized.

Copy link

muzir commented Mar 24, 2017

Be aware of there is no duplicate sourceDirectory in your pom build cycle. Because maven default source location is src/main below extra definiton in my pom.xml cause the same error as above.

I/O operation failed: No source found for

    <sourceDirectory>src/main</sourceDirectory>
    <testSourceDirectory>src/test</testSourceDirectory>
    <resources>
        <resource>
            <directory>src/resource</directory>
        </resource>
    </resources>

After I removed these lines my problem is solved.

You can check this link for good explanation

https://github.com/asciidoctor/asciidoctor/wiki/Coveralls.io-configuration-for-maven-projects

and my project too :)

https://github.com/muzir/azorka.api

@trautonen

This comment has been minimized.

Copy link
Owner

trautonen commented Mar 25, 2017

@muzir this is interesting. I'm not totally sure how maven's runtime source loading works, but the plugin basically uses MavenProject.getCompileSourceRoots() so it "should" see the same sources as maven itself.

Do you have a broken example where the source loading fails with a custom source directory?

The defaults are actually src/main/java, src/test/java and src/main/resources so if your source files (with package directories) are not straight under the defined directories, they are not found. But if they are, then it's worth checking why they are not found.

@muzir

This comment has been minimized.

Copy link

muzir commented Mar 26, 2017

@trautonen please clone this repo and add below lines to pom.xml under build tag.

<sourceDirectory>src/main</sourceDirectory>
    <testSourceDirectory>src/test</testSourceDirectory>
    <resources>
        <resource>
            <directory>src/resource</directory>
        </resource>
    </resources>

Then you need to add <configuration><repoToken>yourToken</repoToken></configuration> for coveralls-maven-plugin and run this command mvn coveralls:report when I do this I get below exception

Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:4.3.0:report (default-cli) on project azorka.api: I/O operation failed: No source found for com/azorka/api/validation/ValidationService.java -> [Help 1]

@alessandrolulli

This comment has been minimized.

Copy link

alessandrolulli commented May 30, 2017

Hello, i am encountering the same issue on a Scala project built with Maven and using Travis.
Please find following my configuration in the pom.xml:

<plugin>
                <groupId>org.eluder.coveralls</groupId>
                <artifactId>coveralls-maven-plugin</artifactId>
                <version>4.3.0</version>
                <configuration>
                    <repoToken>${env.COVERALLS_TOKEN}</repoToken>
                    <sourceEncoding>UTF-8</sourceEncoding>
                </configuration>
            </plugin>
<plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.7.9</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

The .travis.yml

sudo: false
language: java
notifications:
  email:
    on_success: change 
    on_failure: always
script:
    - mvn test jacoco:report
after_success:
    - mvn coveralls:report

Could you please help me?

@alessandrolulli

This comment has been minimized.

Copy link

alessandrolulli commented Jun 8, 2017

Hi, i solved the issue adding the source directory to the list of directories where coveralls searches the sources.
I do not understand why coveralls plugin is not looking in the default source directory.

However, find below my working configurations:

<plugin>
                <groupId>org.eluder.coveralls</groupId>
                <artifactId>coveralls-maven-plugin</artifactId>
                <version>4.3.0</version>
                <configuration>
                    <repoToken>${env.COVERALLS_TOKEN}</repoToken>
                    <sourceEncoding>UTF-8</sourceEncoding>
                    <sourceDirectories>
                        <sourceDirectory>${basedir}/src/main/scala</sourceDirectory>
                    </sourceDirectories>
                </configuration>
            </plugin>

skytreader added a commit to skytreader/chess-templar that referenced this issue Jul 20, 2017

Try to compensate for coveralls plugin bugs.
Viewing source files in Coveralls web fails, saying that the source is not
found. This commit is a trick from trautonen/coveralls-maven-plugin#57.

nfalco79 added a commit to nfalco79/junit4osgi that referenced this issue Oct 23, 2017

@nfalco79

This comment has been minimized.

Copy link

nfalco79 commented Oct 23, 2017

me too here. Coveralls plugin goes in error on a source file of shaded third party jar (embedded as jar for OSGi).

[ERROR] Failed to execute goal org.eluder.coveralls:coveralls-maven-plugin:4.3.0:report (default-cli) on project junit4osgi-parent: I/O operation failed: No source found for org/codehaus/plexus/util/xml/XmlStreamReader.java -> [Help 1]

As workaround I limit jacoco to tracks only my packages to avoid instruct coveralls on third party code.

@JSpiner

This comment has been minimized.

Copy link

JSpiner commented May 31, 2018

I resolved it.
My wrong package name occurs this error.
JSpiner/SafeExecutor@fd4fccb

javatlacati added a commit to javatlacati/regextester that referenced this issue Dec 26, 2018

dhoss added a commit to dhoss/smough that referenced this issue Jan 25, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.