Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Properties properties = new Properties();
- URL url = new App().getClass().getResource(PROPERTIES_FILE);
- properties.load(url.openStream());
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <version>2.2</version>
- <configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
- <archive>
- <manifest>
- <mainClass>com.stackoverflow.App</mainClass>
- </manifest>
- <manifestEntries>
- <Class-Path>.</Class-Path> <!-- HERE IS THE IMPORTANT BIT -->
- </manifestEntries>
- </archive>
- </configuration>
- <executions>
- <execution>
- <id>make-assembly</id> <!-- this is used for inheritance merges -->
- <phase>package</phase> <!-- append to the packaging phase. -->
- <goals>
- <goal>single</goal> <!-- goals == mojos -->
- </goals>
- </execution>
- </executions>
- </plugin>
- java -cp .;filename.jar com.example.YourClassWithMain
- URL root = getClass().getProtectionDomain().getCodeSource().getLocation();
- URL propertiesFile = new URL(root, "filename.properties");
- Properties properties = new Properties();
- properties.load(propertiesFile.openStream());
- Class-Path: .
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*properties</include>
- </includes>
- </resource>
- </resources>
- </configuration>
- <plugin>
- <!-- Create a custom MANIFEST.MF file, setting the classpath. -->
- <delete file="${project.base.dir}/resources/MANIFEST.MF" failonerror="false"/>
- <manifest file="${project.base.dir}/resources/MANIFEST.MF">
- <attribute name="Class-Path" value="." />
- </manifest>
- <!-- JAR the server-side code, using the custom manifest from above. -->
- <jar destfile="services/${name}.aar" manifest="${project.base.dir}/resources/MANIFEST.MF">
- [....]
Add Comment
Please, Sign In to add comment