コード例 #1
0
  private static Dependency parseOldVersionsWithoutSchema(File f) throws JAXBException {
    final JAXBContext context =
        JAXBContext.newInstance(com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Versions.class);
    final Unmarshaller unmarshaller = context.createUnmarshaller();

    final com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Versions versions =
        (com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Versions) unmarshaller.unmarshal(f);

    final Coordinates coordinates = new Coordinates();
    coordinates.setGroupId(versions.getCoordinates().getGroupId());
    coordinates.setArtifactId(versions.getCoordinates().getArtifactId());
    coordinates.setVersion(versions.getCoordinates().getVersion());

    final SCM scm = new SCM();
    scm.setConnection(versions.getScm().getConnection());
    scm.setRevision(versions.getScm().getRevision());

    final Dependency dependency = new Dependency();
    dependency.setCoordinates(coordinates);
    dependency.setScm(scm);

    if (versions.getDependencies() != null) {
      for (com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Dependency d :
          versions.getDependencies()) {
        marshalDependenciesVersionsWithoutSchema(dependency, d);
      }
    }

    return dependency;
  }
コード例 #2
0
  private static void marshalDependenciesVersionsWithoutSchema(
      final Dependency dependency, com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Dependency d) {
    Dependency _d = new Dependency();
    Coordinates depCoorinates = new Coordinates();
    depCoorinates.setGroupId(d.getCoordinates().getGroupId());
    depCoorinates.setArtifactId(d.getCoordinates().getArtifactId());
    depCoorinates.setVersion(d.getCoordinates().getVersion());
    _d.setCoordinates(depCoorinates);

    SCM depSCM = new SCM();
    depSCM.setConnection(d.getScm().getConnection());
    depSCM.setRevision(d.getScm().getRevision());
    _d.setScm(depSCM);
    dependency.addDependency(_d);

    for (com.sap.prd.mobile.ios.mios.versioninfo.v_1_2_0.Dependency __d : d.getDependencies())
      marshalDependenciesVersionsWithoutSchema(_d, __d);
  }
コード例 #3
0
  private static void marshalOldDependencies(
      final Dependency dependency, com.sap.prd.mobile.ios.mios.versioninfo.v_0_0_0.Dependency d) {
    Dependency _d = new Dependency();
    Coordinates depCoorinates = new Coordinates();
    depCoorinates.setGroupId(d.getCoordinates().getGroupId());
    depCoorinates.setArtifactId(d.getCoordinates().getArtifactId());
    depCoorinates.setVersion(d.getCoordinates().getVersion());
    _d.setCoordinates(depCoorinates);

    SCM depSCM = new SCM();
    depSCM.setConnection(
        "scm:perforce:" + d.getScm().getRepository() + ":" + getDepotPath(d.getScm().getPath()));
    depSCM.setRevision(d.getScm().getSnapshotId());
    _d.setScm(depSCM);
    dependency.addDependency(_d);

    for (com.sap.prd.mobile.ios.mios.versioninfo.v_0_0_0.Dependency __d : d.getDependencies())
      marshalOldDependencies(_d, __d);
  }
コード例 #4
0
  private void createVersionInfoFile(
      final String groupId,
      final String artifactId,
      final String version,
      Properties versionInfo,
      List<Dependency> dependencies,
      OutputStream os)
      throws MojoExecutionException, JAXBException {
    try {

      final String connectionString =
          "scm:perforce:"
              + versionInfo.getProperty("port")
              + ":"
              + getDepotPath(versionInfo.getProperty("depotpath"));

      final Versions versions = new Versions();

      for (final Dependency dep : dependencies) versions.addDependency(dep);

      final SCM scm = new SCM();
      scm.setConnection(connectionString);
      scm.setRevision(versionInfo.getProperty("changelist"));

      final Coordinates coordinates = new Coordinates();
      coordinates.setGroupId(groupId);
      coordinates.setArtifactId(artifactId);
      coordinates.setVersion(version);

      versions.setScm(scm);
      versions.setCoordinates(coordinates);

      final JAXBContext context = JAXBContext.newInstance(Versions.class);

      final Marshaller marshaller = context.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
      marshaller.setProperty(
          Marshaller.JAXB_SCHEMA_LOCATION,
          "urn:xml.sap.com:XCodePlugin:VersionInfo"
              + " "
              + NEXUS_URL
              + "/content/repositories/"
              + SCHEMA_REPOSITORY
              + "/"
              + SCHEMA_GROUP_ID.replace(".", "/")
              + "/"
              + SCHEMA_ARTIFACT_ID
              + "/"
              + SCHEMA_VERSION
              + "/"
              + SCHEMA_ARTIFACT_ID
              + "-"
              + SCHEMA_VERSION
              + ".xsd");

      final ByteArrayOutputStream byteOs = new ByteArrayOutputStream();

      marshaller.marshal(versions, byteOs);

      final byte[] b = byteOs.toByteArray();

      DomUtils.validateDocument(
          DocumentBuilderFactory.newInstance()
              .newDocumentBuilder()
              .parse(new ByteArrayInputStream(b)));

      IOUtils.write(b, os);
    } catch (ParserConfigurationException e) {
      throw new MojoExecutionException("Cannot create versions.xml.", e);
    } catch (IOException e) {
      throw new MojoExecutionException("Cannot create versions.xml.", e);
    } catch (SAXException e) {
      throw new MojoExecutionException("Cannot create versions.xml.", e);
    }
  }