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

Document resources configuration support in plugins #180

Open
sbrannen opened this issue Dec 6, 2021 · 4 comments
Open

Document resources configuration support in plugins #180

sbrannen opened this issue Dec 6, 2021 · 4 comments
Labels
documentation Improvements or additions to documentation gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin
Milestone

Comments

@sbrannen
Copy link
Collaborator

sbrannen commented Dec 6, 2021

The documentation for the Gradle and Maven plugins currently does not cover support for configuring resources or auto-detection of resources.

@sbrannen sbrannen added documentation Improvements or additions to documentation gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin labels Dec 6, 2021
@sbrannen sbrannen added this to the 0.9.9 milestone Dec 6, 2021
@YunaBraska
Copy link

YunaBraska commented Dec 7, 2021

There are many configuration options without description. I guess resourceIncludedPatterns that's the option wich should do it, but it doesn't matter what i configure as nearly everything gets ignored.
@sbrannen maybe the following helps?

<configuration>
    <!-- IGNORED -->
    <resourceIncludedPatterns>.*</resourceIncludedPatterns>
    <!-- WORKS -->
    <buildArgs>-H:IncludeResources=.*</buildArgs>
</configuration>

@sdeleuze sdeleuze modified the milestones: 0.9.9, 0.9.10 Dec 20, 2021
@melix melix modified the milestones: 0.9.10, 0.9.11 Feb 14, 2022
@sdeleuze sdeleuze modified the milestones: 0.9.11, 0.9.12 Mar 25, 2022
@ngeor
Copy link

ngeor commented Apr 9, 2022

Thanks @YunaBraska this fixed it for me as well.

I noticed that with ".*" the resulting binary grew 10x in size, even though I only have one small toml file in my resources. So I switched the expression to

              <buildArgs>-H:IncludeResources='.*toml$'</buildArgs>

which did the trick without exploding the size of the image.

@melix melix modified the milestones: 0.9.12, 0.9.13 Jun 21, 2022
@melix melix modified the milestones: 0.9.13, 0.9.14 Jul 12, 2022
@melix melix modified the milestones: 0.9.14, 0.9.15 Sep 19, 2022
@melix melix modified the milestones: 0.9.15, 0.9.16 Oct 17, 2022
@sdeleuze sdeleuze modified the milestones: 0.9.16, 0.9.17 Oct 17, 2022
@sdeleuze sdeleuze modified the milestones: 0.9.17, 0.9.18 Oct 28, 2022
@sdeleuze sdeleuze modified the milestones: 0.9.18, 0.9.19 Nov 14, 2022
@dnestoro dnestoro modified the milestones: 0.9.19, 0.9.20 Dec 2, 2022
@sdeleuze sdeleuze modified the milestones: 0.9.20, 0.9.21 Jan 31, 2023
@dnestoro dnestoro modified the milestones: 0.9.21, 0.9.22 Apr 13, 2023
@dnestoro dnestoro modified the milestones: 0.9.22, 0.9.23 May 11, 2023
@dnestoro dnestoro modified the milestones: 0.9.23, 0.9.24 Jun 16, 2023
@dnestoro dnestoro modified the milestones: 0.9.24, 0.9.25 Aug 9, 2023
@dnestoro dnestoro modified the milestones: 0.9.25, 0.9.26 Aug 28, 2023
@olpaw olpaw modified the milestones: 0.9.26, 0.9.27 Sep 7, 2023
@olpaw olpaw modified the milestones: 0.9.27, 0.9.28 Sep 18, 2023
@bdshadow
Copy link

according to maven docs https://maven.apache.org/guides/mini/guide-configuring-plugins.html#mapping-collection-types it must be like this:

<configuration>
	<resourceIncludedPatterns>
		<resourceIncludedPattern>application.properties</resourceIncludedPattern>
	</resourceIncludedPatterns>
</configuration>

however it doesn't work for me too. I'm reading application.properties with getResourceAsStream, so java-agent was able to find it added the following to the resource-config.json:

{
    "pattern":"\\Qapplication.properties\\E"
  }

So i tried it the same for the maven plugin:

<configuration>
	<resourceIncludedPatterns>
		<resourceIncludedPattern>\\Qapplication.properties\\E</resourceIncludedPattern>
	</resourceIncludedPatterns>
</configuration>

but it still doesn't work.
Meanwhile i'll leave it with the java-agent to find the file for me, it's fine for me. But the maven plugin definitely has some problem... or it's just badly documented as it is actually stated in the header of the issue

@bdshadow
Copy link

bdshadow commented Jan 4, 2024

I have finally found it. It is not described anywhere, but is present in the samples in this repo: https://github.com/graalvm/native-build-tools/blob/master/samples/java-application-with-resources/pom.xml#L102

So you need to execute the generateResourceConfig goal before the build. The following works for me

<plugin>
	<groupId>org.graalvm.buildtools</groupId>
	<artifactId>native-maven-plugin</artifactId>
	<version>${native.maven.plugin.version}</version>
	<extensions>true</extensions>
	<executions>
		<execution>
			<id>build-native</id>
			<goals>
				<goal>generateResourceConfig</goal>
				<goal>build</goal>
			</goals>
			<phase>package</phase>
		</execution>
		<execution>
			<id>test-native</id>
			<goals>
				<goal>test</goal>
			</goals>
			<phase>test</phase>
		</execution>
	</executions>
	<configuration>
		<fallback>false</fallback>
		<resourceIncludedPatterns>
			<pattern>application.properties</pattern>
		</resourceIncludedPatterns>
	</configuration>
</plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation gradle-plugin Related to Gradle plugin maven-plugin Related to Maven plugin
Projects
None yet
Development

No branches or pull requests

8 participants