0

I started using maven some days ago, I was trying to use a jquery calendar tool so when I tried to add dependencies maven putted a WAR dependency, I was curious I opened it and really it contains the necessary import classes. but my IDE tell me that the import is not resolved !!! I don't understand what is happening, I searched to know what is a war, I founded that is web java application. Is it impossible to use a war as a library ? Is this the reason why my import is not working ?

below my pom,setting xml files and the import in the java code

pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.mycompany</groupId>
        <artifactId>gestion_stock</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>

        <repositories>
            <repository>
                <id>sonatype-snapshots</id>
                <name>Sonatype Snapshots Repository</name>
                <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories> 

        <dependencies>
            <dependency>
                <groupId>com.googlecode.wicket-jquery-ui</groupId>
                <artifactId>wicket-jquery-ui</artifactId>
                <version>8.0.0-M3</version>
            </dependency>
            <dependency>
                <groupId>com.googlecode.wicket-jquery-ui</groupId>
                <artifactId>jquery-ui-calendar</artifactId>
                <version>6.2.2</version>
            </dependency>
            <dependency>
                <groupId>com.googlecode.wicket-jquery-ui</groupId>
                <artifactId>jquery-ui-core</artifactId>
                <version>6.2.2</version>
            </dependency>
            <dependency>
                <groupId>org.wicketstuff</groupId>
                <artifactId>wicketstuff-bundle</artifactId>
                <version>8.0.0-SNAPSHOT</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.googlecode.wicket-jquery-ui</groupId>
                <artifactId>wicket-jquery-ui-calendar</artifactId>
                <version>8.0.0-SNAPSHOT</version>
                <type>jar</type>
            </dependency>
            <dependency>
                <groupId>com.googlecode.wicket-jquery-ui</groupId>
                <artifactId>wicket-jquery-ui-samples</artifactId>
                <version>8.0.0-SNAPSHOT</version>
                <type>war</type>
            </dependency>
        </dependencies>
        <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.8</maven.compiler.source>
            <maven.compiler.target>1.8</maven.compiler.target>
        </properties>
    </project>

setting.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
        User-specific configuration for maven. Includes things that should not 
        be distributed with the pom.xml file, such as developer identity, along with 
        local settings, like proxy information. The default location for the
        settings file is ~/.m2/settings.xml 
    -->
    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
        <!--proxies>
            <proxy>
                <host>my.proxy.host</host>
            </proxy>
        </proxies-->

        <!--pluginGroups>
            <pluginGroup>org.codehaus.mojo</pluginGroup>
        </pluginGroups-->
    </settings>

ExtendedCalendarPage.java

    package com.talcorp.gestion_stock;

    import java.time.LocalDateTime;
    import java.time.temporal.ChronoUnit;
    import java.util.Date;

    import org.apache.wicket.ajax.AjaxRequestTarget;
    import org.apache.wicket.markup.html.form.Form;
    import org.apache.wicket.markup.html.panel.FeedbackPanel;

    import com.googlecode.wicket.jquery.core.Options;
    import com.googlecode.wicket.jquery.ui.calendar.Calendar;
    import com.googlecode.wicket.jquery.ui.calendar.CalendarView;
    import com.googlecode.wicket.jquery.ui.panel.JQueryFeedbackPanel;
    // the non working imports in the wicket-jquery-ui-samples-8.0.0-SNAPSHOOT.war
    import com.googlecode.wicket.jquery.ui.samples.component.DemoCalendarDialog;
    import com.googlecode.wicket.jquery.ui.samples.data.DemoCalendarEvent;
    import com.googlecode.wicket.jquery.ui.samples.data.DemoCalendarModel;
    import com.googlecode.wicket.jquery.ui.samples.data.dao.CalendarDAO;

    public class ExtendedCalendarPage extends AbstractCalendarPage
    {
            private static final long serialVersionUID = 1L;

            private Calendar calendar;

            .

            .

            .

    }

NB: the war is stored in the project in a file named : Non-classpath-dependencies

thanks

1 Answers1

2

Maven has a plugin for this case, It should be present in the war application/library - which creates a classes artifact.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
        <attachClasses>true</attachClasses>
    </configuration>
</plugin>

This, you can refer in your project using below

<dependency>
    <groupId>your-group-id</groupId>
    <artifactId>your-artifact-id</artifactId>
    <version>your-version</version>
    <classifier>classes</classifier>
</dependency>
Srikanth Balaji
  • 2,638
  • 4
  • 18
  • 31