Search code examples
weblogicartifactory

Deploy to weblogic without Artifactory


Is there a way to deploy a war file to Weblogic via maven without sending a version to Artifactory?

Here is my pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <name>... Maven Webapp</name>
      <repositories>
        <repository>
            <id>...</id>
            <name>...</name>
            <url>...</url>
        </repository>
    </repositories>
    <build>
        <finalName>${project.artifactId}</finalName>
        <sourceDirectory>${project.basedir}/src</sourceDirectory>
        <outputDirectory>${project.basedir}/target/classes</outputDirectory>
        <resources>
            <resource>
                <targetPath>content</targetPath>
                <directory>WEB-INF</directory>
                <includes>
                    <include>Language-ext.properties</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                    <configuration>
                        <source>1.5</source>
                        <target>1.5</target>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <webXml>${project.basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.oracle.weblogic</groupId>
                    <artifactId>weblogic-maven-plugin</artifactId>
                    <version>10.3.4</version>
                    <configuration>
                        <adminurl>${wls.admin.url}</adminurl>
                        <user>${wls.admin.username}</user>
                        <password>${wls.admin.password}</password>
                        <upload>true</upload>
                        <stage>true</stage>
                        <action>deploy</action>
                        <verbose>true</verbose>
                        <source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
                        <name>${project.build.finalName}</name>
                        <targets>${deploy.targets}</targets>
                        <usenonexclusivelock>true</usenonexclusivelock>
                        <artifactLocation>
                           C:\temp\portlet.war
                        </artifactLocation>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <dependencies>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.14</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-asm</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc-portlet</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>...</groupId>
            <artifactId>...</artifactId>
            <version>2.0.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>...</groupId>
          <artifactId>...</artifactId>
          <version>8.2</version>
        </dependency>
        <dependency>
            <groupId>...</groupId>
            <artifactId>...</artifactId>
            <version>10.0.51</version>
            <scope>provided</scope>
        </dependency>
        <dependency>        
            <groupId>br.com.gvt.portlets</groupId>
            <artifactId>BasePortlet</artifactId>
            <version>2.0.0</version>            
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>wl-local</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <wls.admin.url>t3://...</wls.admin.url>
                <wls.admin.username>...</wls.admin.username>
                <wls.admin.password>...</wls.admin.password>
                <deploy.remote>true</deploy.remote>
                <deploy.targets>...</deploy.targets>
            </properties>

            <pluginRepositories>
                <pluginRepository>
                    <id>...</id>
                    <name>...</name>
                    <url>...</url>
                </pluginRepository>
            </pluginRepositories>

        </profile>

        <profile>
            <id>wl-remote</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>

            <properties>
                <wls.admin.url>${adminurl}</wls.admin.url>
                <wls.admin.username>${user}</wls.admin.username>
                <wls.admin.password>${password}</wls.admin.password>
                <deploy.remote>true</deploy.remote>
                <deploy.targets>${targets}</deploy.targets>
            </properties>
        </profile>
    </profiles>
    <distributionManagement>
        <repository>
            <uniqueVersion>false</uniqueVersion>
            <id>corp1</id>
            <name>Corporate Repository</name>
            <url>file:C:/temp/</url>
            <layout>default</layout>
        </repository>
    </distributionManagement>
</project>

With this configuration when I use mvn deploy it saves a lot of files including the war file in C:\temp


Solution

  • We've solved the issue, I can deploy to weblogic with eclipse Run as maven build...

    On the Goals attribute I put:

    wls:undeploy -DmiddlewareHome=C:\Oracle\Middleware\Oracle_Home -DweblogicHome=C:\Oracle\Middleware\Oracle_Home\wlserver -Dadminurl=t3://host:7000 -Duser=user -Dpassword=password -Dtargets=targets -Dname=nameofproject -Dremote=false -Dupload=true wls:redeploy -DmiddlewareHome=C:\Oracle\Middleware\Oracle_Home -DweblogicHome=C:\Oracle\Middleware\Oracle_Home\wlserver -Dadminurl=t3://host:7000 -Duser=user -Dpassword=password -Dtargets=targets -Dname=nameofproject -Dremote=false -Dupload=true

    and using a settings.xml file on the User settings field like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <profiles>
        <profile>
          <repositories>
            <repository>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
              <id>central</id>
              <name>libs-releases</name>
              <url>http://host:8081/artifactory/libs-releases</url>
            </repository>
            <repository>
              <snapshots />
              <id>snapshots</id>
              <name>libs-snapshots</name>
              <url>http://host:8081/artifactory/libs-snapshots</url>
            </repository>
          </repositories>
          <pluginRepositories>
            <pluginRepository>
              <snapshots>
                <enabled>false</enabled>
              </snapshots>
              <id>central</id>
              <name>plugins-releases</name>
              <url>http://host:8081/artifactory/plugins-releases</url>
            </pluginRepository>
            <pluginRepository>
              <snapshots />
              <id>snapshots</id>
              <name>plugins-snapshots</name>
              <url>http://host:8081/artifactory/plugins-snapshots</url>
            </pluginRepository>
          </pluginRepositories>
          <id>artifactory</id>
        </profile>
      </profiles>
      <activeProfiles>
        <activeProfile>artifactory</activeProfile>
      </activeProfiles>
    
      <pluginGroups>
         <pluginGroup>com.oracle.weblogic</pluginGroup>
     </pluginGroups> 
    </settings>
    

    It lasts some time to undeploy and deploy the war file, but it's better than doing manually.

    Thank you all.