Skip to main content

Maven Project Configuration

The project uses Maven as its build tool with Java 21 as the target platform.

Project Coordinates

groupId
string
com.mycompany
artifactId
string
Refactorizacion-ALFA
version
string
1.0-SNAPSHOT
modelVersion
string
4.0.0

Java Configuration

Compiler Settings

The project is configured to use Java 21 for both source and target compatibility:
<properties>
    <maven.compiler.source>21</maven.compiler.source>
    <maven.compiler.target>21</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
maven.compiler.source
string
default:"21"
Java source version for compilation
maven.compiler.target
string
default:"21"
Java target version for bytecode generation
project.build.sourceEncoding
string
default:"UTF-8"
Character encoding for source files

Dependencies

Runtime Dependencies

Artifact: org.xerial:sqlite-jdbcVersion: 3.41.2.1Purpose: Provides JDBC connectivity to SQLite databases
<dependency>
    <groupId>org.xerial</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.41.2.1</version>
</dependency>
Usage: Database operations in InventarioDAO
Artifact: com.toedter:jcalendarVersion: 1.4Purpose: Provides JDateChooser component for date selection in Swing UI
<dependency>
    <groupId>com.toedter</groupId>
    <artifactId>jcalendar</artifactId>
    <version>1.4</version>
</dependency>
Usage: Date picker widgets in view dialogs

Test Dependencies

Artifact: org.junit.jupiter:junit-jupiterVersion: 5.10.0Scope: testPurpose: Unit testing framework for JUnit 5
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.10.0</version>
    <scope>test</scope>
</dependency>
Usage: Writing and running unit tests

Build Plugins

Maven Compiler Plugin

Compiles Java source code to bytecode.
groupId
string
org.apache.maven.plugins
artifactId
string
maven-compiler-plugin
version
string
3.13.0
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.13.0</version>
    <configuration>
        <source>21</source>
        <target>21</target>
    </configuration>
</plugin>
The compiler plugin explicitly sets Java 21 as both source and target version, ensuring compatibility.

Maven JAR Plugin

Creates a standard JAR file with manifest configuration.
groupId
string
org.apache.maven.plugins
artifactId
string
maven-jar-plugin
version
string
3.2.2
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>3.2.2</version>
    <configuration>
        <archive>
            <manifest>
                <mainClass>InventarioApp</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>
Main Class: InventarioApp
This plugin creates a standard JAR that requires external dependencies to be in the classpath.

Maven Shade Plugin

Creates an executable “fat JAR” with all dependencies bundled.
groupId
string
org.apache.maven.plugins
artifactId
string
maven-shade-plugin
version
string
3.3.0
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <createDependencyReducedPom>true</createDependencyReducedPom>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>InventarioApp</mainClass>
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>
Features:
  • Bundles all dependencies into a single JAR
  • Creates an executable JAR with proper manifest
  • Generates a dependency-reduced POM
  • Runs during the package phase
The shade plugin creates Refactorizacion-ALFA-1.0-SNAPSHOT.jar with all dependencies included, making deployment easier.

Database Configuration

Connection URL

The database connection is configured in InventarioDAO constructor:
String carpetaBD = "./db";
File folderFile = new File(carpetaBD);
if (!folderFile.exists()) {
    folderFile.mkdirs();
}
this.dbUrl = "jdbc:sqlite:" + carpetaBD + "/baseDeDatosInventario.db";
carpetaBD
string
default:"./db"
Directory for database file storage (relative to application location)
dbUrl
string
JDBC connection URL in format: jdbc:sqlite:./db/baseDeDatosInventario.db

Connection Properties

PropertyValueDescription
Driver Classorg.sqlite.JDBCSQLite JDBC driver
Database FilebaseDeDatosInventario.dbSQLite database filename
Auto-committrue (default)Automatically commit transactions
Connection ReuseYesSingle connection instance reused

Custom Database Location

To specify a custom database location, pass a JDBC URL to the DAO constructor:
String customUrl = "jdbc:sqlite:/path/to/database.db";
InventarioDAO dao = new InventarioDAO(customUrl);

Build Commands

Compile the Project

mvn compile
Compiles Java source files to target/classes/.

Run Tests

mvn test
Executes JUnit tests located in src/test/java/.

Package Application

mvn package
Creates two JAR files in target/:
  1. Standard JAR: Refactorizacion-ALFA-1.0-SNAPSHOT.jar
  2. Fat JAR: Refactorizacion-ALFA-1.0-SNAPSHOT-shaded.jar (with dependencies)

Clean Build

mvn clean package
Removes target/ directory and rebuilds from scratch.

Run Application

From Maven

mvn exec:java -Dexec.mainClass="InventarioApp"

From JAR (requires dependencies in classpath)

java -jar target/Refactorizacion-ALFA-1.0-SNAPSHOT.jar

From Fat JAR (self-contained)

java -jar target/Refactorizacion-ALFA-1.0-SNAPSHOT-shaded.jar

Project Structure

Refactorizacion-ALFA/
├── pom.xml                          # Maven configuration
├── src/
│   ├── main/
│   │   └── java/
│   │       ├── InventarioApp.java   # Main entry point
│   │       ├── controller/
│   │       │   └── InventarioController.java
│   │       ├── model/
│   │       │   └── InventarioDAO.java
│   │       └── view/
│   │           ├── InventarioView.java
│   │           ├── AgregarMedicamentoView.java
│   │           ├── EditarMedicamentoView.java
│   │           ├── VentasView.java
│   │           ├── RegistrarVentaView.java
│   │           ├── EditarVentaView.java
│   │           ├── ApartadosView.java
│   │           ├── RegistrarApartadoView.java
│   │           └── EditarApartadoView.java
│   └── test/
│       └── java/                    # Unit tests (if any)
├── target/                          # Build output
└── db/                              # Database directory (created at runtime)
    └── baseDeDatosInventario.db

Environment Requirements

Java Runtime
JRE/JDK
required
Java 21 or higher required to run the application
Maven
Build Tool
Maven 3.x required for building from source
Operating System
OS
Cross-platform (Windows, macOS, Linux) - uses SQLite and Java Swing
Display
GUI
Graphical display required (X11, Windows Display, macOS window manager)

Dependency Tree

Refactorizacion-ALFA:1.0-SNAPSHOT
├── org.xerial:sqlite-jdbc:3.41.2.1
├── com.toedter:jcalendar:1.4
└── org.junit.jupiter:junit-jupiter:5.10.0 (test)
    ├── org.junit.jupiter:junit-jupiter-api:5.10.0
    ├── org.junit.jupiter:junit-jupiter-params:5.10.0
    └── org.junit.jupiter:junit-jupiter-engine:5.10.0
The application has minimal external dependencies, making it lightweight and easy to deploy.

IDE Configuration

IntelliJ IDEA

  1. Open the project as a Maven project
  2. Ensure Java 21 SDK is configured
  3. Maven will auto-import dependencies
  4. Run configuration: Main class = InventarioApp

Eclipse

  1. Import as “Existing Maven Project”
  2. Configure Java 21 JDK in project properties
  3. Update Maven project to resolve dependencies
  4. Run as Java Application with InventarioApp as main class

VS Code

  1. Open folder with Java and Maven extensions installed
  2. Extensions will detect pom.xml
  3. Select Java 21 runtime
  4. Run using “Run Java” or Maven commands

Build docs developers (and LLMs) love