CopyPastor

Detecting plagiarism made easy.

Score: 0.8031082153320312; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2023-03-19
by Stephen Parry

Original Post

Original - Posted on 2010-09-22
by Vijay Katam



            
Present in both answers; Present only in the new answer; Present only in the old answer;

If you are using Maven and the original library is available there, you can use the `add-module-info` goal of the [moditect plugin][1]. Below is a snippet of pom.xml I used to patch the h2 jdbc driver and engine. The plugin creates a patched copy of the plugin in `${project.build.directory}/modules` which can then be used e.g. jlinked in.
<plugin> <groupId>org.moditect</groupId> <artifactId>moditect-maven-plugin</artifactId> <version>1.0.0.RC2</version> <executions> <execution> <id>add-module-infos</id> <phase>generate-resources</phase> <goals> <goal>add-module-info</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/modules</outputDirectory> <modules> <module> <artifact> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>2.1.214</version> </artifact> <moduleInfoSource> module com.h2database { requires java.compiler; requires jdk.net; requires static lucene.core; requires static lucene.queryparser; requires static slf4j.api; requires static jakarta.servlet; requires transitive java.desktop; requires transitive java.instrument; requires java.logging; requires transitive java.management; requires static java.naming; requires transitive java.scripting; requires java.sql; requires transitive java.transaction.xa; requires transitive java.xml; requires static javax.servlet.api; requires static org.locationtech.jts; requires static org.osgi.service.jdbc; requires static osgi.core; provides java.sql.Driver with org.h2.Driver; } </moduleInfoSource> </module> </modules> </configuration> </execution> </executions> </plugin>

[1]: https://github.com/moditect/moditect
Use the *maven-shade-plugin* to package all dependencies into one über-JAR file. It can also be used to build an executable JAR file by specifying the main class. After trying to use maven-assembly and maven-jar, I found that this plugin best suited my needs.
I found this plugin particularly useful as it merges the content of specific files instead of overwriting them. This is needed when there are resource files that are have the same name across the JAR files and the plugin tries to package all the resource files.
See the example below:
<plugins> <!-- This plugin provides the capability to package the artifact in an über-JAR file, including its dependencies and to shade - i.e. rename - the packages of some of the dependencies. --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.4</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <artifactSet> <!-- Signed JAR files--> <excludes> <exclude>bouncycastle:bcprov-jdk15</exclude> </excludes> </artifactSet>
<transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <!-- Main class --> <mainClass>com.main.MyMainClass</mainClass> </transformer>
<!-- Use resource transformers to prevent file overwrites --> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>properties.properties</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer"> <resource>applicationContext.xml</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/cxf/cxf.extension</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.XmlAppendingTransformer"> <resource>META-INF/cxf/bus-extensions.xml</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins>




        
Present in both answers; Present only in the new answer; Present only in the old answer;