lburgazzoli / gradle-karaf-plugin

Apache License 2.0
21 stars 13 forks source link

Kar not generated after updating to Gradle 5.1-rc-3 #64

Closed realPyR3X closed 5 years ago

realPyR3X commented 5 years ago

After upgrading to Gradle 5.1-rc-3 a KAR file is no longer produced in the build/karaf/kar directory. In fact, it's not created at all. Everything works as expected in Gradle 5.0.

lburgazzoli commented 5 years ago

I have not tested it at all in 5.x do you mind to help?

On Sat, 22 Dec 2018 at 18:32, realPyR3X notifications@github.com wrote:

After upgrading to Gradle 5.1-rc-3 a KAR file is no longer produced in the build/karaf/kar directory. In fact, it's not created at all. Everything works as expected in Gradle 5.0.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lburgazzoli/gradle-karaf-plugin/issues/64, or mute the thread https://github.com/notifications/unsubscribe-auth/AByEhVT2JRxS2LgMYKCc718l2Rx1Bi0Aks5u7my3gaJpZM4ZfjSF .

--

Luca Burgazzoli

realPyR3X commented 5 years ago

Yes. I'm up against a tight deadline right now but afterward I will help.

V/r,

-Charlie

realPyR3X commented 5 years ago

The issue with Gradle 5.1 is an API change to AbstractArchiveTask (inherited from Zip and then Jar). They have made the properties such as 'archiveExtension' and 'archiveBaseName' private and final. The way to change them would be 'getArchiveBaseName().set('features.name')', however, we cannot do this in the copy method because it won't take effect. It needs to be done in the constructor but if we access the getKaraf().features singleton it will resolve to the wrong location since it was called at the wrong time. I don't know how to fix this so I'm going to just update my code base to hardcode a location for now.

realPyR3X commented 5 years ago

Hi Luca,

While the correct calls are being made now, this didn't resolve the original issue. I have a distribution task that uses a CopySpec to 'from generateKar' to copy the created KAR to a directory. The values are defaulting to 'project.name-project.version.jar' in the libs directory instead of 'features.name-features.version.kar' in the 'build/karaf/kar' directory.

Things will work if you set the archive properties in the KarafKarTask constructor but not in the copy method. I don't know why this is the case. Does it generate to the appropriate directory for you?

Thanks,

-Charlie

lburgazzoli commented 5 years ago

can you send a pr to test your issue? there is a test case you can use as a base.

That woukd help me to understand the problem

On Sat, 5 Jan 2019 at 19:18, realPyR3X notifications@github.com wrote:

Hi Luca,

While the correct calls are being made now, this didn't resolve the original issue. I have a distribution task that uses a CopySpec to 'from generateKar' to copy the created KAR to a directory. The values are defaulting to 'project.name-project.version.jar' in the libs directory instead of 'features.name-features.version.kar' in the 'build/karaf/kar' directory.

Things will work if you set the archive properties in the KarafKarTask constructor but not in the copy method. I don't know why this is the case. Does it generate to the appropriate directory for you?

Thanks,

-Charlie

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/lburgazzoli/gradle-karaf-plugin/issues/64#issuecomment-451678707, or mute the thread https://github.com/notifications/unsubscribe-auth/AByEhRhurknOTLT71UqDkD0LIvkSvvP_ks5vAOx4gaJpZM4ZfjSF .

--

Luca Burgazzoli

cetra3 commented 5 years ago

@lburgazzoli I have this issue too. Is this task closed because it's resolved in newer versions of the plugin?

lburgazzoli commented 5 years ago

It should be part of version, 0.5.1 If the issue is not solved, can you send a pr with a test reproducer ?

cetra3 commented 5 years ago

It doesn't appear to be resolved. I can see that the features and kar directory are present, but no kar archive is created.

Steps to replicate are easy, but I'm not sure how you want me to shape the PR:

cetra3 commented 5 years ago

@lburgazzoli Can I get your help on how best to approach the PR?

realPyR3X commented 5 years ago

@cetra3 check your build/libs directory it should generate the project-version.jar there. This is actually the kar file and you can just rename the file appropriately in Gradle. It will take some investigation as to why this is happening I deduced the issue before but recall at the time not knowing a good solution.

cetra3 commented 5 years ago

Here's a workaround for anyone wanting to resolve this until it's fixed properly:

task tempFix(type: Copy) {
    from("$buildDir/libs")
    into("$buildDir/karaf/kar")
    rename {
        String fileName -> 
            fileName.replace('.jar', '.kar')
    }
}

generateKar.finalizedBy tempFix