Skip to content

DateTimeExtensions Not Working in Jar #344

@jbird-zwicker

Description

@jbird-zwicker

I am making use of the toDate() method in the DateTimeExtensions class, from the groovy-dateutil library.

In my project, when run via the IDE, this code works as expected:

Date d = LocalDate.now().toDate()

However, when the project is compiled to a Jar with gmavenplus, this line instead throws an exception:

Exception in thread "AWT-EventQueue-0" groovy.lang.MissingMethodException: No signature of method: java.time.LocalDate.toDate() is applicable for argument types: () values: []
Possible solutions: format(java.time.format.DateTimeFormatter), isCase(java.lang.Object), tap(groovy.lang.Closure), get(java.time.temporal.TemporalField), getAt(java.lang.String), putAt(java.lang.String, java.lang.Object)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
	at org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:163)
	at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)

Below is my POM with sensitive information excluded:

pom.xml ``` 4.0.0
<groupId>ORG</groupId>
<artifactId>PROJECT</artifactId>
<version>1.0-SNAPSHOT</version>


<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<repositories>
    <!-- internal repository redacted -->
</repositories>

<dependencies>
    <!-- https://mvnrepository.com/artifact/com.github.lgooddatepicker/LGoodDatePicker -->
    <dependency>
        <groupId>com.github.lgooddatepicker</groupId>
        <artifactId>LGoodDatePicker</artifactId>
        <version>11.2.1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.miglayout/miglayout-swing -->
    <dependency>
        <groupId>com.miglayout</groupId>
        <artifactId>miglayout-swing</artifactId>
        <version>5.3</version>
    </dependency>
    <!-- internal dependency redacted -->
    <!-- internal dependency redacted -->
    <!-- internal dependency redacted -->
    <!-- internal dependency redacted -->
    <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.10.2</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy-dateutil</artifactId>
        <version>4.0.14</version>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.apache.groovy</groupId>
        <artifactId>groovy-all</artifactId>
        <version>4.0.14</version>
        <type>pom</type>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.spockframework/spock-core -->
    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>2.4-M5-groovy-4.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>


<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <version>4.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>addSources</goal>
                        <goal>addTestSources</goal>
                        <goal>generateStubs</goal>
                        <goal>compile</goal>
                        <goal>generateTestStubs</goal>
                        <goal>compileTests</goal>
                        <goal>removeStubs</goal>
                        <goal>removeTestStubs</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <finalName>PROJECT</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <archive>
                    <manifest>
                        <mainClass>ORG.PROJECT.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions