create master encryption in settings-security.xml. use mvn encrypt-master-password <key>
<settingsSecurity>
<master>{W8KhSWMsODYH965ChH+0L2ec0aP8BUathXuBPdQTDzc=}</master>
</settingsSecurity>
Then use mvn-encrypt-password <password> and use it in the password tags in settings.xml.
You can add custom text outside the braces, i.e. meta info about the password
Java dev
Søk i denne bloggen
torsdag 29. september 2011
mandag 26. september 2011
Using deploy:deploy-file goal
Adding 3rd party jar files to nexus with deploy:deploy-file:
If pom file is not provided, use:
mvn deploy:deploy-file -Durl=http://host...:8081/nexus/content/repositories/thirdparty/ \
-DrepositoryId=nexus \
-Dfile=....sqlworkbench.jar \
-DgroupId=com.sql \
-DartifactId=sql-workbench \
-Dversion=1.0 \
-Dpackaging=jar \
-DgeneratePom=true \
-DgeneratePom.description="SQL workbench by Thomas Kellerer"
If pom file is not provided, use:
mvn deploy:deploy-file -Durl=http://host...:8081/nexus/content/repositories/thirdparty/ \
-DrepositoryId=nexus \
-Dfile=....sqlworkbench.jar \
-DgroupId=com.sql \
-DartifactId=sql-workbench \
-Dversion=1.0 \
-Dpackaging=jar \
-DgeneratePom=true \
-DgeneratePom.description="SQL workbench by Thomas Kellerer"
torsdag 22. september 2011
Creating executable jar with dependencies
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
søndag 18. september 2011
Introduction to Maven
Maven
According to the official maven site at apache, maven is a software project management and comprehension tool. Maven can manage a project's build, reporting and documentation from a central piece of information.
Main objectives:
According to the official maven site at apache, maven is a software project management and comprehension tool. Maven can manage a project's build, reporting and documentation from a central piece of information.
Main objectives:
- Making the build process easy
- Providing a uniform build system
- Providing quality project information
- Providing guidelines for best practices development
- Allowing transparent migration to new features
Maven 2 lifecycle phases (By John Ferguson Smart, JavaWorld.com, 12/05/05, javaworld)
Nexus
Nexus manages software artifacts required for development, deployment, and provisioning. If you develop software, Nexus can help you share those artifacts with other developers and end-users.
See also introduction to lifecycle
Introduction to the POM
A Project Object Model or POM is the fundamental unit of work in Maven. It is an XML file that contains information about the project and configuration details used by Maven to build the project.Nexus
Nexus manages software artifacts required for development, deployment, and provisioning. If you develop software, Nexus can help you share those artifacts with other developers and end-users.
søndag 11. september 2011
Uploading artifacts to nexus repository
1) Ensure that snapshot cleaning is turned on in nexus, purging old snapshots at certain intervals.
http://www.sonatype.com/people/2009/09/nexus-scheduled-tasks/
2) add
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<name>Nexus staging repo</name>
<url>http://host:8081/nexus/content/repositories/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
to your root aggregator pom. Note that snapshotRepository is not a release repository, hence new snapshots can be deployed with mvn deploy goal.
3) Add authentication of nexus host in the settings file.
<server>
<id>nexus</id>
<username>deployment</username>
<password>password</password>
</server>
4) Run mvn deploy on the root aggregator. The artifacts are uploaded.
http://www.sonatype.com/people/2009/09/nexus-scheduled-tasks/
2) add
<distributionManagement>
<snapshotRepository>
<id>nexus</id>
<name>Nexus staging repo</name>
<url>http://host:8081/nexus/content/repositories/snapshots/</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>
to your root aggregator pom. Note that snapshotRepository is not a release repository, hence new snapshots can be deployed with mvn deploy goal.
3) Add authentication of nexus host in the settings file.
<server>
<id>nexus</id>
<username>deployment</username>
<password>password</password>
</server>
4) Run mvn deploy on the root aggregator. The artifacts are uploaded.
fredag 9. september 2011
Bash script to migrate from Ant to Maven
S="
if [ -d "$S" ]; then
TJ="
TR="
mkdir -p $TJ
mkdir -p $TR
echo copying $S/* to $TJ
# clean java and resource directories
find $TJ \( ! -regex '.*/\..*' \) -type f -exec rm {} \;
find $TR \( ! -regex '.*/\..*' \) -type f -exec rm {} \;
# syncronize files
rsync -a -u -m --include="+ *.java" --exclude="- *.*" --exclude=".*" "$S"/* "$TJ" 2>/dev/null
rsync -a -u -m --include="+ *.form" --exclude="- *.*" --exclude=".*" "$S"/* "$TJ" 2>/dev/null
rsync -a -u -m --include="+ *.properties" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.wsmode" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.xml" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.html" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.shadow" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.png" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.PNG" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.jpg" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.JPG" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.gif" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.GIF" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.sql" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
rsync -a -u -m --include="+ *.r" --exclude="- *.*" --exclude=".*" "$S"/* "$TR" 2>/dev/null
# recursively remove empty directories
find $TJ -type d -print | xargs rmdir 2>/dev/null
find $TR -type d -print | xargs rmdir 2>/dev/null
fi
Difference between Ant and Maven project structure
Key differences between Ant and Maven
1) Source directory:
Ant: src
Maven: src/main/java and src/main/resources,
Note: Maven is splitting java files from the resource files(.xml, .png, etc). The form files is is still in the java dir.
2) Test directory
Ant: test/unit/src
Maven: src/test/java and src/test/resources
1) Source directory:
Ant: src
Maven: src/main/java and src/main/resources,
Note: Maven is splitting java files from the resource files(.xml, .png, etc). The form files is is still in the java dir.
2) Test directory
Ant: test/unit/src
Maven: src/test/java and src/test/resources
Abonner på:
Innlegg (Atom)