skrapeit / skrape.it

A Kotlin-based testing/scraping/parsing library providing the ability to analyze and extract data from HTML (server & client-side rendered). It places particular emphasis on ease of use and a high level of readability by providing an intuitive DSL. It aims to be a testing lib, but can also be used to scrape websites in a convenient fashion.
https://docs.skrape.it
MIT License
789 stars 57 forks source link

[FEATURE] Support for native image (Spring Native/GraalVM) #201

Closed marceligrabowski closed 1 year ago

marceligrabowski commented 1 year ago

Is your feature request related to a problem? Please describe. I was wondering if it's bug report or feature request but it would be nice to have support for native image building e.g. Spring Native. Currently skrape.it added as dependency instantly fails build process. It might be connected to usage of logback.xml here. I did small reproduction of this problem with logback and it turned out that it can fail build while having logback.xml in classpath

Describe the solution you'd like Skrape.it supporting native image building.

Additional context

  - Additional action of task ':generateAot' was implemented by the Java lambda 'org.springframework.aot.gradle.SpringAotGradlePlugin$$Lambda$916/0x00000008012f5230'. Reason: Using Java lambdas is not supported as task inputs. Please refer to https://docs.gradle.org/7.5/userguide/validation_problems.html#implementation_unknown for more details about this problem.
I 11:19:13.722 [ld.ContextBootstrapContributor] Detected application class: pl.something.api.ApiApplication
I 11:19:13.724 [ld.ContextBootstrapContributor] Processing application context

org.springframework.boot.logging.LogbackHints$LogbackXmlException: Embedded logback.xml file is not supported yet with Spring Native, read the support section of the documentation for more details

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':generateAot'.
> Process 'command '/Users/user/.sdkman/candidates/java/22.2.r17-grl/bin/java'' finished with non-zero exit value 1

It might be related to https://github.com/spring-projects-experimental/spring-native/issues/625

christian-draeger commented 1 year ago

Hey, Thx for pointing this out. The library should not hinder native image compilation. As you already mentioned logback could be the problem here. Can you provide a pull request?

marceligrabowski commented 1 year ago

@christian-draeger I'll try prepare something this week ;)

christian-draeger commented 1 year ago

Thank you 🙌

marceligrabowski commented 1 year ago

Okay. For now the most obvious thing to do is to remove logback.xml but I suspect that it's not welcomed solution. I'll try with setting up logback config programatically - not through xml file

christian-draeger commented 1 year ago

Sounds like a good idea. I had same problem in spring projects that uses native image compilation and logback-spring.xml. Migrating away from logback.xml fixed this problem and was easy in that case because logger can be configured via application.yaml as well. Not sure how to do in none spring projects. But in general not using logback.xml seems to be a good and pragmatic solution.

marceligrabowski commented 1 year ago

@christian-draeger Just added PR with changes. It looks like it works like a charm 🎉

christian-draeger commented 1 year ago

Thx a lot :) will merge it tomorrow

marceligrabowski commented 1 year ago

As #203 is merged we can consider it as closed completed 🥳✅ Release of new version in near future would be helpful. Maybe after #202 is resolved (I can take a look at it)