powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Java [игнор отключен] [закрыт для гостей] / Сборка maven-проекта
6 сообщений из 6, страница 1 из 1
Сборка maven-проекта
    #38051165
Как запаковать отдельно стоящий jar в основной jar при сборке maven-проекта?
...
Рейтинг: 0 / 0
Сборка maven-проекта
    #38051193
Фотография Denis Popov
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
On 23.11.2012 19:35, Степовой А. С. wrote:

> Как запаковать отдельно стоящий jar в основной jar при сборке maven-проекта?

Посмотри на Maven Assembly plugin: http://maven.apache.org/plugins/maven-assembly-plugin/

Posted via ActualForum NNTP Server 1.5
...
Рейтинг: 0 / 0
Сборка maven-проекта
    #38051260
Фотография dmitriyche
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Степовой А. С.,

Посмотрите в сторону Apache Shade plugin .
Вот пример использования
И ещё один пример - там Java Mail API и MySQL Connector запаковывается в целевой jar.
...
Рейтинг: 0 / 0
Сборка maven-проекта
    #38051430
marx_freedom
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
Сборка maven-проекта
    #38051572
dominator
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
...
Рейтинг: 0 / 0
Сборка maven-проекта
    #38051594
Фотография oson
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Код: xml
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
<build>
        <plugins>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>jarjar-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jarjar</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>com.sun.media:jai_imageio</include>
                                <include>com.sun.media:jai-codec</include>
                            </includes>
                            <rules>
                                <rule>
                                    <pattern>com.sun.media.**</pattern>
                                    <result>my.cool.app.@1<;/result>
                                </rule>
                                <keep>
                                    <pattern>my.cool.app.**</pattern>
                                </keep>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>



Примерно вот так.
По поводу

Код: xml
1.
2.
<pattern>com.sun.media.**</pattern>
<result>my.cool.app.@1<;/result>



то заменит имена пакетов вначале - то есть если был например com.sun.media.jai.Class1, то получится my.cool.app.jai.Class1.

Насчет

Код: xml
1.
2.
3.
<keep>
<pattern>my.cool.app.**</pattern>
</keep>


надо уточнить. Можно посмотреть тут

http://code.google.com/p/jarjar/wiki/CommandLineDocs

jarjar wikiThe rules file is a text file, one rule per line. Leading and trailing whitespace is ignored. There are three types of rules:

rule <pattern> <result>
zap <pattern>
keep <pattern>
The standard rule (rule) is used to rename classes. All references to the renamed classes will also be updated. If a class name is matched by more than one rule, only the first one will apply.

<pattern> is a class name with optional wildcards. ** will match against any valid class name substring. To match a single package component (by excluding . from the match), a single * may be used instead.

<result> is a class name which can optionally reference the substrings matched by the wildcards. A numbered reference is available for every * or ** in the <pattern>, starting from left to right: @1, @2, etc. A special @0 reference contains the entire matched class name.

The zap rule causes any matched class to be removed from the resulting jar file. All zap rules are processed before renaming rules.

The keep rule marks all matched classes as "roots". If any keep rules are defined all classes which are not reachable from the roots via dependency analysis are discarded when writing the output jar. This is the last step in the process, after renaming and zapping.
...
Рейтинг: 0 / 0
6 сообщений из 6, страница 1 из 1
Форумы / Java [игнор отключен] [закрыт для гостей] / Сборка maven-проекта
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]