Skip to content

Allow URL(s) as source in jsonschema2pojo-gradle-plugin - #1554

Merged
joelittlejohn merged 3 commits into
joelittlejohn:masterfrom
unkish:issues/1010
Sep 22, 2024
Merged

joelittlejohn merged 3 commits into
joelittlejohn:masterfrom
unkish:issues/1010

Conversation

@unkish

@unkish unkish commented Aug 10, 2023

Copy link
Copy Markdown
Collaborator

Closes #1010

Seems it got broken with #748, specifically this line.

Note: users would have to explicitly invoke clean whenever they have URL as source and know that content behind URL has changed

@unkish

unkish commented Aug 10, 2023 •

Copy link
Copy Markdown
Collaborator Author

Looks like JsonSchemaPluginSpec::java is executed prior snapshot artifact is generated causing build failure.
Reverting changes from build.gradle would help but there would be no "test" to validate the fix later on.

@joelittlejohn any thoughts on how to proceed ?

One way to validate my claim would be to rename JsonSchemaPluginSpec to JsonSchemaPluginSpecIT and add following section to jsonschema2pojo-gradle-plugin\pom.xml:

            <plugin>
                <!-- switch off surefire, there's no unit tests in this module -->
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

@joelittlejohn

Copy link
Copy Markdown
Owner

Ah yes, thanks @unkish. I had noticed this a while back, when there was some problem in the plugin but it did not get shown until after an install.

I think your solution to use failsafe instead of surefire and attach it to a later phase is a good one 👍

Is this ready to merge now?

@unkish

unkish commented Aug 11, 2023 •

Copy link
Copy Markdown
Collaborator Author

In last change that succeeded I've split test into unit (jsonschema2pojo-gradle-plugin/src/test/groovy/org/jsonschema2pojo/gradle/JsonSchemaPluginSpec.groovy) and integration test (jsonschema2pojo-gradle-plugin/src/integrationTest/groovy/org/jsonschema2pojo/gradle/GradleBuildIT.groovy) and configured jsonschema2pojo-gradle-plugin to execute both: failsafe and surefie.

I can switch it to run only failsafe and disable surefire - would that be preferred way ?

@unkish

unkish commented Aug 11, 2023 •

Copy link
Copy Markdown
Collaborator Author

@joelittlejohn adjusted jsonschema2pojo-gradle-plugin such that it would only execute maven-failsafe-plugin in install phase and skip running maven-surefire-plugin.
With these changes it should be ready (if there is nothing that I've missed)

@joelittlejohn

joelittlejohn commented Aug 11, 2023 •

Copy link
Copy Markdown
Owner

Sorry @unkish I misunderstood. I didn't realise there were unit tests. I'm happy to use surefire and failsafe, each for the appropriate kind of test.

@unkish

unkish commented Aug 12, 2023 •

Copy link
Copy Markdown
Collaborator Author

@joelittlejohn no worries.

I have one concern though: it seems that at present github actions will skip integration tests in jsonschema2pojo-gradle-plugin as:

      - name: Verify with Maven
        run: mvn verify -B

will not trigger it since verify is prior install phase, and

      - name: Install latest jsonschema2pojo SNAPSHOT
        run: mvn -U -B install -DskipTests -Dmaven.javadoc.skip -Dmaven.site.skip

will not trigger it due -DskipTests.


I would imagine that something like:

      - name: Verify with Maven
        run: mvn verify -B
      - name: Verify jsonschema2pojo-gradle-plugin integration tests
        run: mvn -U -B install -DskipTests -Dmaven.javadoc.skip -Dmaven.site.skip -pl jsonschema2pojo-gradle-plugin -am
        run: mvn -U -B install -pl jsonschema2pojo-gradle-plugin

would "remedy" the issue, however I'm not sure whether it is an overall good solution or not

@joelittlejohn joelittlejohn added this to the 1.2.3 milestone Sep 22, 2024
@joelittlejohn
joelittlejohn merged commit 1476474 into joelittlejohn:master Sep 22, 2024
@unkish
unkish deleted the issues/1010 branch September 23, 2024 09:51
@ctrimble ctrimble mentioned this pull request Oct 19, 2025
@joelittlejohn joelittlejohn modified the milestones: 1.2.3, 1.3.0 Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL as source not working in latest releases

2 participants