Exclude Java classes for an Angular Project While Scan

  • ALM used : Bitbucket Cloud
  • CI system used Bitbucket Pipelines
  • Scanner command used when applicable:
  • pipe: sonarsource/sonarcloud-scan:1.2.
  • pipe: sonarsource/sonarcloud-quality-gate:0.1.4
  • Languages of the repository Javascript/TypeScript

The angular repo has Java Files and we tried to exclude the Java classes using sonar.coverage.exclusions

ERROR: Error during SonarScanner execution

org.sonar.java.AnalysisException: Your project contains .java files, please provide compiled classes with sonar.java.binaries property, or exclude them from the analysis with sonar.exclusions property.

at org.sonar.java.classpath.ClasspathForMain.init(ClasspathForMain.java:75)

at org.sonar.java.classpath.AbstractClasspath.getElements(AbstractClasspath.java:317)

at org.sonar.java.SonarComponents.getJavaClasspath(SonarComponents.java:169)

Can we add excluding the classes in the scan

Hi @sonar2

You said you tries to exclude the Java classes using sonar.coverage.exclusions.
This property only excludes files from test coverage computation, not from the whole analysis.

The error message advises to use another property to exclude the Java files from the analysis: sonar.exclusions.

Have you tried using that other property instead?
If you need help configuring the exclusion pattern, here is the documentation.


doing the below:

  • pipe: sonarsource/sonarcloud-scan:1.2.1
    EXTRA_ARGS: ‘-Dsonar.exclusions=/*.java,/*.json’

the error does not show up.

The problem is the angular repo is a mono repo and the bitbucket pipelines stops at the end without giving any analysis due to “container exceeding memory limit”

Tried increasing the memory and pass SONAR_SCANNER_OPTS: -Xmx4096m

But not success.

Can you let me know any other options.


The memory consumption issue is a very known one and using SONAR_SCANNER_OPTS does not increase the memory available to the container.
The solution is explained on the link on that post.
In short:

  • Add the size: 2x parameter to the pipeline step, to give more memory to the step
  • Allocate that memory to the docker container (you can increase the value up to 7128 with a 2x step)
      memory: 2048


I have the size:2x parameter in every step, but the service memory in definitions @ 2048 it stops at the after the code is scanned and before the quality gate complaining of memory.

I did increase to 7128 it stops in the beginning of the pipeline.

Have you tried any other value between 2048 and 7128, to find one big enough to run the analysis but small enough to be supported by the pipeline environment?
Could you please post the full logs ?

Tying with 4096

ERROR: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '["../../node_modules","../../tmp"]'.
ERROR: Cannot read file '/opt/atlassian/pipelines/agent/build/libs/pages/biobytes/biobytes-home/tsconfig.spec.json'.
ERROR: Failed to parse tsconfig: /opt/atlassian/pipelines/agent/build/libs/pages/biobytes/biobytes-home/tsconfig.spec.json (Cannot read file '/opt/atlassian/pipelines/agent/build/libs/pages/biobytes/biobytes-home/tsconfig.spec.json'.)
INFO: 5992 source files to be analyzed
INFO: Analyzing 45 files using tsconfig: /opt/atlassian/pipelines/agent/build/apps/ic-me-sciencare-mobile/tsconfig.editor.json
INFO: 0/5992 files analyzed, current file: apps/ic-me-sciencare-mobile/src/environments/environments.model.ts
INFO: Skipping 954 files with no tsconfig.json
INFO: Analyzing 13 files using tsconfig: /opt/atlassian/pipelines/agent/build/libs/castle-shared-components/tsconfig.lib.json
INFO: Analyzing 9 files using tsconfig: /opt/atlassian/pipelines/agent/build/libs/pages/back-office/ic-me-admin-dashboard/tsconfig.lib.json
INFO: 58/5992 files analyzed, current file: libs/facilities/src/lib/containers/facilities-page/facilities-page.component.ts
INFO: 58/5992 files analyzed, current file: libs/facilities/src/lib/containers/facilities-page/facilities-page.component.ts
INFO: 58/5992 files analyzed, current file: libs/facilities/src/lib/containers/facilities-page/facilities-page.component.ts
time="2021-09-13T13:56:04Z" level=error msg="error waiting for container: unexpected EOF"

I have a question, submitted a scan last night, the pipeline says it is failed because the sonar-quality-gate was not run.

When I look at the background tasks of the project it says successful and there is no coverage report. Can you take a look at the below id and let me know why the quality gate was not run and why the pipelines say it is failed.

background id: AXvdaainPHEC-AA0s-LW

Is it on the same project or on another one?
If it’s another issue, could you please open another thread? It would help keeping this one clean and the investigation easier.

Could you please post the full logs, complete, from the start of the step to the error?

Have you tried any other values, to see if a compromise with the apparently invalid 7128, and the too small 4096 can be found?

I see a lot of files on your project. Have you tried narrowing down the analyzed files, by excluding some directories, to find if a very big file or directory could cause the issue?
If you can isolate a given file or directory that makes the analysis fail, then we would be able to investigate further.