百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

core

> 开发工具
开源

Forge 核心框架 API 和实现

199 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

Forge 核心框架 API 和实现

image::http://design.jboss.org/jbossforge/logo/final/jbossforge_logo_600px.png[]

The fastest way to build applications, share your software, and enjoy doing it.

image:https://github.com/forge/core/workflows/GitHub%20CI/badge.svg["Actions Status", link="https://github.com/forge/core/actions"] image:https://img.shields.io/github/license/forge/core.svg["License", link="https://www.eclipse.org/legal/epl-v10.html"] image:https://maven-badges.herokuapp.com/maven-central/org.jboss.forge/forge-distribution/badge.svg["Maven Central", link="https://maven-badges.herokuapp.com/maven-central/org.jboss.forge/forge-distribution"] image:https://kiwiirc.com/buttons/irc.freenode.net/forge.png["Visit our IRC channel", link="https://kiwiirc.com/client/irc.freenode.net/#forge"]

What's new and noteworthy?

  • JDK 11: Forge 3 now runs on JDK 11 as its minimum requirement. Hello lambdas!

  • Unix-like option names: The shell option names are now more unix-like: Eg: --targetPackage is now --target-package.

== Download Forge 3: JBoss Forge is packaged inside your favorite IDE plugin and also as a standalone ZIP file. They are independent of each other.

  • Eclipse - http://tools.jboss.org/
  • IntelliJ IDEA - http://plugins.jetbrains.com/plugin/7515
  • NetBeans - http://plugins.netbeans.org/plugin/57296/
  • Command line tools

=== Get Started with the Command line tools:

Getting started with the command line tools is easy:

  • Download a distribution .. Download link:https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=org.jboss.forge&a=forge-distribution&v=LATEST&e=zip&c=offline[JBoss Forge - Offline (Recommended)] ... This ZIP contains the Forge runtime + Core Addons .. Download link:https://oss.sonatype.org/service/local/artifact/maven/redirect?r=releases&g=org.jboss.forge&a=forge-distribution&v=LATEST&e=zip[JBoss Forge - No Addons] ... This ZIP contains the Forge runtime only

  • Extract the ZIP to a directory and navigate to forge-distribution-VERSION/bin directory

  • Execute forge by running [source,cmd]


forge

Forge is now ready to go.

==== Install addons (not needed if using the offline zip)

Install the required addons by running the following commands:

[source,cmd]

forge --install groupId:artifactId,version

  • Forge will install the required dependencies for each addon.

IMPORTANT: Make sure your settings.xml is properly configured to use the Maven central repository or, if you wish to use a SNAPSHOT version from a core addon, the JBoss Nexus Repository, otherwise the installation will fail. Instructions on how to setup your settings.xml can be found on https://community.jboss.org/wiki/MavenGettingStarted-Developers

If you wish to install the core addons including the shell, "Project: New", the "Java EE" commands, and all other provided functionality, you should run the following command:

[source,cmd]

forge --install core

If you only wish to install the Forge 2 Shell based on link:http://aeshell.github.io/[Aesh], run the following command instead:

[source,cmd]

forge --install shell

If you wish to remove any addon, you can use the following command:

[source,cmd]

forge --remove groupId:artifactId,version

== Get Started with the Eclipse Plugin:


Forge 3 is known to work with Eclipse Mars (Eclipse 4.5) or higher versions. Older versions of Eclipse are not supported.


  • Install the JBoss Tools Usage Reporting plugin, available in http://download.jboss.org/jbosstools/updates/development/mars/ and restart Eclipse
  • Install the Forge Eclipse Plugin from http://download.jboss.org/jbosstools/mars/snapshots/updates// and restart Eclipse

This plugin starts the Forge Container and your installed addons, so you can use them directly in your workspace

  • Press Ctrl + 4 to show the installed addons that you may interact with (these addons use the UI addon, hence providing a user interface - see Developing an UI Addon for more details).

== Available addons

[options="header"] |=== |Addon name |Included in Eclipse Plugin ?

|link:addon-manager/README.asciidoc[Addon Manager] |yes

|link:addons/README.asciidoc[Addons] |yes

|link:configuration/README.asciidoc[Configuration] |yes

|link:convert/README.asciidoc[Convert] |yes

|link:dependencies/README.asciidoc[Dependencies] |yes

|link:dev-tools-java/README.asciidoc[Dev Tools - Java] |yes

|link:environment/README.asciidoc[Environment] |yes

|link:facets/README.asciidoc[Facets] |yes

|link:git/README.asciidoc[Git] |yes

|link:javaee/README.asciidoc[Java EE] |yes

|link:maven/README.asciidoc[Maven] |yes

|link:parser-java/README.asciidoc[Parser Java] |yes

|link:parser-json/README.asciidoc[Parser Json] |yes

|link:parser-xml/README.asciidoc[Parser XML] |yes

|link:projects/README.asciidoc[Projects] |yes

|link:resources/README.asciidoc[Resources] |yes

|link:scaffold/README.asciidoc[Scaffold] |yes

|link:shell/README.asciidoc[Shell] |yes

|link:templates/README.asciidoc[Templates] |yes

|link:text/README.asciidoc[Text] |yes

|link:ui/README.asciidoc[User Interface (UI)] |yes

|===

== Developing an Addon

Forge addons are simple Maven projects with a special classifier "forge-addon". This classifier is used while installing an addon so the Furnace container can calculate its dependencies, freeing you from http://robjsoftware.org/2007/07/13/classloader-hell/[Classloader hell].

One of the most important things to know about developing a Forge addon, is that the Furnace runtime container (the core of Forge), is actually an embeddable, modular Java container. This means that each addon has its own ClassLoader and that addons share classes from each other, in addition to supplying their own local classes. Furnace builds a graph of addon dependencies at runtime, and automatically calculates which addons should see classes from other addons.

For now, however, just treat your first addon as if it were any other Java project. The differences between a "modular" and "traditional" environment are not as great as you might think, and the Furnace development model has been created in a way that should make these differences seem natural, almost transparent.

=== Create a Maven project

Forge Addons must be JARs published with a 'forge-addon' classifier. Add this plugin configuration to your pom.xml:

[source,xml]

     org.apache.maven.plugins
     maven-jar-plugin
     
        
           create-forge-addon
           package
           
              jar
           
           false
           
              forge-addon

In order to use CDI and services from other addons in your addon, you'll need to reference the Furnace CDI container addon as a dependency your pom.xml file:

[source,xml]

org.jboss.forge.furnace.container cdi forge-addon provided


CAUTION: Addon dependencies MUST be declared in the Maven pom.xml that produces your forge-addon classified artifact; otherwise, Furnace will NOT use this dependency as a forge-addon. Instead, addon dependencies declared via transitive dependencies will be included as local JAR files and re-bundled with your addon. More than likely, re-bundling a forge-addon in your Addon is NOT what you want.

Your complete POM should now look something like this:

[source,xml]

4.0.0

com.example example 1.0.0-SNAPSHOT

My First Addon

    3.5.1.Final



    
        
            org.jboss.forge
            forge-bom
            ${version.forge}
            pom
            import
        
    



  
     org.jboss.forge.furnace.container
     cdi
     forge-addon
     provided
  



  
     
        org.apache.maven.plugins
        maven-jar-plugin
        
           
              create-forge-addon
              package
              
                 jar
              
              false
              
                 forge-addon

=== Add behavior to your addon

A service is implemented as a POJO (Plain Old Java Object):

[source,java]

public class ExampleServiceImpl { public String doSomething() { // Do stuff... }

}

However, best practices favor creating a service interface, otherwise consumers will be required to request your specific service implementation. For example:

[source,java]

public interface ExampleService { public String doSomething(); }

Then simply implement the service interface:

[source,java]

public class ExampleServiceImpl implements ExampleService { public String doSomething() { // Do stuff... }

}

=== Re-use functionality from other addons:

Forge has a modular architecture that enables you to re-use functionality from other addons, directly in your own addon code. In order to achieve this, you must add addon-dependencies in your pom.xml file.

[source,xml]

...

     org.jboss.forge.addon
     resources
     forge-addon
     provided
  
  
     org.jboss.forge.addon
     ui
     forge-addon
     provided
  

  
  
     org.jboss.forge.furnace.container
     cdi
     forge-addon
     provided

...


==== What scope should my addon dependencies be?

There is a simple rule that will make this an easy decision:


"compile if everyone knows, provided if I know, runtime if nobody knows."


To explain, if you never publicly expose types (classes, interfaces, etc...) from another addon in the outward-facing APIs of your addon, then you should include that addon as provided scope. If you do, however, expose classes from that addon in the public APIs of your code, then that addon should be labeled as compile scope (default,) which means that this dependency will be 'exported' to consumers that depend on your addon.

Addon dependencies may also be made optional if consumers of your addon should be able to choose whether or not certain functionality is enabled, or if your addon behaves differently when other addons are already deployed to the container.

The following chart explains this in detail. Assume that our addon depends on the resources addon, which provides the ResourceFactory and FileResource classes:

[cols="1a,2,3", options="header"] |=== |Example |Scope should be |Explanation

| The Resource and ResourceFactory types are provided by the resources addon. Your addon defines InternalExample.

[source,java]

public class InternalExample { @Inject private ResourceFactory factory;

public void doSomething(File file) { Resource r = factory.create(file); System.out.println("New resource: " + r)a }

}

|provided |Consumers of your addon never see classes or interfaces from the resources addon; it is only used internally as an implementation detail and is not exposed in your public API.

Your addon should depend on the resources addon at provided scope.

| The Resource and ResourceFactory types are provided by the resources addon. Your addon defines ExposedExample.

[source,java]

public class ExposedExample { @Inject private ResourceFactory factory;

public Resource doSomething(File file) { Resource r = factory.create(file); return r; }

}

|compile |Consumers of your addon require classes from the resources addon to interact with your code, since it has been referenced in the your addon's public API.

Your addon should depend on the resources addon at compile scope.

| The type LockCreator is defined by addon X.

[source,java]

public class LockCreator { public void creat

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Javaidejavajavaeejboss

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类开发工具
定价开源

> 相关工具

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具