[GRADLE-1288] Osgi/Java build fails if no Java sources are in the source dirs Created: 05/Jan/11  Updated: 10/Feb/17  Resolved: 10/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.1
Fix Version/s: None

Type: Bug
Reporter: Zoltan Lear Assignee: Unassigned
Resolution: Won't Fix Votes: 5

Issue Links:
Duplicate
Duplicated by GRADLE-982 Jar task fails when the osgi plugin i... Resolved
Duplicated by GRADLE-2391 osgi plugin fails to jar if there are... Resolved

 Description   

The following gradle build.gradle file fails if no Java source file is available:

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'osgi'

the build failure doesn't appear if you
either comment out the 'apply plugin osgi' line in the build.gradle file
or you put any valid java class into the /src/main/java directory e.g. :

public class AnyClass {}

gradle output is:

 
E:\tmp\test>gradle clean build -S
HELLO FROM INIT BEFORE PROJECT: test
:clean
:compileJava
:processResources UP-TO-DATE
:classes
:jar

FAILURE: Build failed with an exception.

* What went wrong:
Could not copy MANIFEST.MF to 'E:\tmp\test\build\tmp\jar\MANIFEST.MF'.

* Try:
Run with -d option to get more details.

* Exception is:
org.gradle.api.GradleException: Could not copy MANIFEST.MF to 'E:\tmp\test\build\tmp\jar\MANIFEST.MF'.
        at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:65)
        at org.gradle.api.internal.file.MapFileTree$FileVisitDetailsImpl.getFile(MapFileTree.java:125)
        at org.gradle.api.internal.file.AbstractFileTree$1.visitFile(AbstractFileTree.java:38)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree$1.visitFile(AbstractFileTree.java:135)
        at org.gradle.api.internal.file.MapFileTree$Visit.visit(MapFileTree.java:95)
        at org.gradle.api.internal.file.MapFileTree.visit(MapFileTree.java:60)
        at org.gradle.api.internal.file.AbstractFileTree$FilteredFileTree.visit(AbstractFileTree.java:126)
        at org.gradle.api.internal.file.AbstractFileTree.getFiles(AbstractFileTree.java:36)
        at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:37)
        at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:37)
        at org.gradle.api.internal.file.CompositeFileCollection.getFiles(CompositeFileCollection.java:37)
        at org.gradle.api.internal.file.AbstractFileCollection.iterator(AbstractFileCollection.java:60)
        at org.gradle.api.internal.changedetection.DefaultFileSnapshotter.snapshot(DefaultFileSnapshotter.java:42)
        at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.calcCurrentState
(DefaultTaskArtifactStateRepository.java:143)
        at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.isUpToDate(Defau
ltTaskArtifactStateRepository.java:153)
        at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(D
efaultTaskArtifactStateRepository.java:292)
        at org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactStateRepository$1.isUpToDate(ShortCircuitTask
ArtifactStateRepository.java:35)
        at org.gradle.api.internal.project.taskfactory.ExecutionShortCircuitTaskExecuter.execute(ExecutionShortCircuitTa
skExecuter.java:40)
        at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExecuter.java:57)
        at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecuter.java:35)
        at org.gradle.api.internal.tasks.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:32)
        at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:231)
        at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
        at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
        at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
        at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
        at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:153)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75)
        at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
        at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
        at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:209)
        at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:193)
        at org.gradle.launcher.Main.execute(Main.java:55)
        at org.gradle.launcher.Main.main(Main.java:40)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
        at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
        at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: java.lang.IllegalArgumentException: Problem opening JAR: E:\tmp\test\build\classes\main
        at aQute.lib.osgi.ZipResource.build(ZipResource.java:63)
        at aQute.lib.osgi.ZipResource.build(ZipResource.java:33)
        at aQute.lib.osgi.Jar.<init>(Jar.java:36)
        at aQute.lib.osgi.Jar.<init>(Jar.java:55)
        at aQute.lib.osgi.Analyzer.setJar(Analyzer.java:699)
        at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.setAnalyzerProperties(DefaultOsgiManifest.java:90)
        at org.gradle.api.internal.plugins.osgi.DefaultOsgiManifest.getEffectiveManifest(DefaultOsgiManifest.java:64)
        at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:152)
        at org.gradle.api.java.archives.internal.DefaultManifest.writeTo(DefaultManifest.java:36)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaM
ethodSite.java:229)
        at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
        at org.gradle.api.tasks.bundling.Jar$_closure1_closure3.doCall(Jar.groovy:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
        at groovy.lang.Closure.call(Closure.java:282)
        at groovy.lang.Closure.call(Closure.java:295)
        at org.gradle.api.internal.file.MapFileTree$FileVisitDetailsImpl.copyTo(MapFileTree.java:143)
        at org.gradle.api.internal.file.AbstractFileTreeElement.copyFile(AbstractFileTreeElement.java:72)
        at org.gradle.api.internal.file.AbstractFileTreeElement.copyTo(AbstractFileTreeElement.java:60)
        ... 42 more


BUILD FAILED

Total time: 2.281 secs


 Comments   
Comment by Niclas Hedhman [ 03/Mar/11 ]

This is a duplicate of GRADLE-982

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 10/Feb/17 ]

Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved.

Generated at Wed Jun 30 11:51:44 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.