-
Notifications
You must be signed in to change notification settings - Fork 20
Maven project with Eclipse
Make sure JRE version 1.6 or later is installed and used in Eclipse and Maven.
-
Check your java version on the command line.
java -version
-
Check the compiler version in 'pom.xml'. It is recommended to specify the version with 'source' and 'target' tags.
<plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
-
Check settings on 'Project > Properties > Java compiler' in Eclipse
-
Add the repository of 'http://jcenter.bintray.com' in 'pom.xml'.
<repositories> .... <repository> <id>bintray</id> <url>http://jcenter.bintray.com</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
-
Add the dependency in 'pom.xml'.
<dependency> <groupId>org.adrianwalker</groupId> <artifactId>multiline-string</artifactId> <version>0.1.1</version> </dependency>
-
Go to 'Help > Install New Software ' menu in Eclipse.
-
Click 'already installed?' link.
-
find 'm2e-Maven integration for Eclipse', or 'm2eclipse' on 'Installed Software' tab.
- If you cannot find installed m2eclipse, go to Step 4 in this page.
- If the version is 0.13 or greater, Step 5 in this page.
- If the version is 0.12 or less, Step 6 in this page.
Step 4 : Install 'm2e' plugin
- Go to 'Help > Install New Software ' menu in Eclipse.
- Click 'Add' button and fill 'Name' and 'Location' field.
- Name : m2e (or m2 eclipse)
- Location : http://download.eclipse.org/technology/m2e/releases
Step 5 : Install 'm2e-apt' plugin.
- Go to 'Help > Install New Software ' menu in Eclipse.
- Click 'Add' button and fill 'Name' and 'Location' field.
- Name : m2e-apt
- Location : http://download.jboss.org/jbosstools/updates/m2e-extensions/m2e-apt
- Go to 'Project > Properties > Maven > Annotation Processing' menu
- Select 'Enable project specific settings'
- Select 'Automatically configure JDT APT'
You have two ways to add 'Factory Path' and select one of them. Both ways will create '.factorypath' file on your project folder.
-
Add 'apt-maven-plugin' plugin in 'pom.xml'.
<build> .... <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>apt-maven-plugin</artifactId> <version>1.0-alpha-5</version> </plugin> .... </plugins> </buiod>
-
Execute 'apt:eclipse' goal on the command line.
mvn apt:eclipse
-
Refresh(F5) your project in Eclipse.
-
Go to 'Project > Properties > Java compiler > Annotation Processing > Factroy Path' menu.
-
Click 'Add Variable'.
-
Select 'M2_REPO' and click 'Extend' button.
-
Select 'multiline-string-....jar' from 'org/adrianwalker/multiline/multiline-string/...' folder.
- Go to 'Project > Properties > Java compiler > Annotation Processing ' menu.
- Select 'Enable project specific settings'
- Select 'Enable annotation processing'.
Create a class for test and run it. The following example shows how to use the @Multiline annotation.
import org.adrianwalker.multilinestring.Multiline;
public class Hello {
/**
Hello!
Multiline-string!!
*/
@Multiline private static String msg;
public static void main(String[] args) {
System.out.println(msg);
}
}
It will write the following message to the console.
Hello!
Multiline-string!!